﻿(function() {
  var mw = window.MetawebSuite;
  mw.system.flagPackageAsCompiled("metaweb-suite-core");
  mw.system.flagPackageAsCompiled("metaweb-suite-ui");
  mw.system.flagPackageAsCompiled("metaweb-suite-freebase");
  mw.system.flagPackageAsCompiled("metaweb-suite-search-widgets");
  mw.system.flagPackageAsCompiled("metaweb-suite-schema-widgets");
  mw.system.flagPackageAsCompiled("metaweb-suite-parallax-model");
  mw.system.flagPackageAsCompiled("metaweb-suite-topic-renderings");
  mw.system.flagPackageAsCompiled("metaweb-suite-views");
  mw.system.flagPackageAsCompiled("metaweb-suite-parallax");
  mw.system.flagPackageAsCompiled("metaweb-suite-persistence");
})();


/* core-package.js */
(function() {
    mw.system.onStartLoadingNativePackage(
        "core",
        [   "externals/jquery-1.2.6.min.js",
            "externals/json2.js",
            "externals/rison.js",
            
            "externals/jquery-ui-personalized-1.5.2.packed.js",
            "externals/jquery.cookie.js",
            
            "listener-queue.js",
            "jsonp-queue.js",
            "string.js",
            "misc.js",
            "terminal.js"
        ],
        [   // no CSS
        ]
    );
})();


/* core-bundle.js */


/* jquery-1.2.6.min.js */
(function(){var _jQuery=window.jQuery,_$=window.$;
var jQuery=window.jQuery=window.$=function(selector,context){return new jQuery.fn.init(selector,context);
};
var quickExpr=/^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,isSimple=/^.[^:#\[\.]*$/,undefined;
jQuery.fn=jQuery.prototype={init:function(selector,context){selector=selector||document;
if(selector.nodeType){this[0]=selector;
this.length=1;
return this;
}if(typeof selector=="string"){var match=quickExpr.exec(selector);
if(match&&(match[1]||!context)){if(match[1]){selector=jQuery.clean([match[1]],context);
}else{var elem=document.getElementById(match[3]);
if(elem){if(elem.id!=match[3]){return jQuery().find(selector);
}return jQuery(elem);
}selector=[];
}}else{return jQuery(context).find(selector);
}}else{if(jQuery.isFunction(selector)){return jQuery(document)[jQuery.fn.ready?"ready":"load"](selector);
}}return this.setArray(jQuery.makeArray(selector));
},jquery:"1.2.6",size:function(){return this.length;
},length:0,get:function(num){return num==undefined?jQuery.makeArray(this):this[num];
},pushStack:function(elems){var ret=jQuery(elems);
ret.prevObject=this;
return ret;
},setArray:function(elems){this.length=0;
Array.prototype.push.apply(this,elems);
return this;
},each:function(callback,args){return jQuery.each(this,callback,args);
},index:function(elem){var ret=-1;
return jQuery.inArray(elem&&elem.jquery?elem[0]:elem,this);
},attr:function(name,value,type){var options=name;
if(name.constructor==String){if(value===undefined){return this[0]&&jQuery[type||"attr"](this[0],name);
}else{options={};
options[name]=value;
}}return this.each(function(i){for(name in options){jQuery.attr(type?this.style:this,name,jQuery.prop(this,options[name],type,i,name));
}});
},css:function(key,value){if((key=="width"||key=="height")&&parseFloat(value)<0){value=undefined;
}return this.attr(key,value,"curCSS");
},text:function(text){if(typeof text!="object"&&text!=null){return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(text));
}var ret="";
jQuery.each(text||this,function(){jQuery.each(this.childNodes,function(){if(this.nodeType!=8){ret+=this.nodeType!=1?this.nodeValue:jQuery.fn.text([this]);
}});
});
return ret;
},wrapAll:function(html){if(this[0]){jQuery(html,this[0].ownerDocument).clone().insertBefore(this[0]).map(function(){var elem=this;
while(elem.firstChild){elem=elem.firstChild;
}return elem;
}).append(this);
}return this;
},wrapInner:function(html){return this.each(function(){jQuery(this).contents().wrapAll(html);
});
},wrap:function(html){return this.each(function(){jQuery(this).wrapAll(html);
});
},append:function(){return this.domManip(arguments,true,false,function(elem){if(this.nodeType==1){this.appendChild(elem);
}});
},prepend:function(){return this.domManip(arguments,true,true,function(elem){if(this.nodeType==1){this.insertBefore(elem,this.firstChild);
}});
},before:function(){return this.domManip(arguments,false,false,function(elem){this.parentNode.insertBefore(elem,this);
});
},after:function(){return this.domManip(arguments,false,true,function(elem){this.parentNode.insertBefore(elem,this.nextSibling);
});
},end:function(){return this.prevObject||jQuery([]);
},find:function(selector){var elems=jQuery.map(this,function(elem){return jQuery.find(selector,elem);
});
return this.pushStack(/[^+>] [^+>]/.test(selector)||selector.indexOf("..")>-1?jQuery.unique(elems):elems);
},clone:function(events){var ret=this.map(function(){if(jQuery.browser.msie&&!jQuery.isXMLDoc(this)){var clone=this.cloneNode(true),container=document.createElement("div");
container.appendChild(clone);
return jQuery.clean([container.innerHTML])[0];
}else{return this.cloneNode(true);
}});
var clone=ret.find("*").andSelf().each(function(){if(this[expando]!=undefined){this[expando]=null;
}});
if(events===true){this.find("*").andSelf().each(function(i){if(this.nodeType==3){return ;
}var events=jQuery.data(this,"events");
for(var type in events){for(var handler in events[type]){jQuery.event.add(clone[i],type,events[type][handler],events[type][handler].data);
}}});
}return ret;
},filter:function(selector){return this.pushStack(jQuery.isFunction(selector)&&jQuery.grep(this,function(elem,i){return selector.call(elem,i);
})||jQuery.multiFilter(selector,this));
},not:function(selector){if(selector.constructor==String){if(isSimple.test(selector)){return this.pushStack(jQuery.multiFilter(selector,this,true));
}else{selector=jQuery.multiFilter(selector,this);
}}var isArrayLike=selector.length&&selector[selector.length-1]!==undefined&&!selector.nodeType;
return this.filter(function(){return isArrayLike?jQuery.inArray(this,selector)<0:this!=selector;
});
},add:function(selector){return this.pushStack(jQuery.unique(jQuery.merge(this.get(),typeof selector=="string"?jQuery(selector):jQuery.makeArray(selector))));
},is:function(selector){return !!selector&&jQuery.multiFilter(selector,this).length>0;
},hasClass:function(selector){return this.is("."+selector);
},val:function(value){if(value==undefined){if(this.length){var elem=this[0];
if(jQuery.nodeName(elem,"select")){var index=elem.selectedIndex,values=[],options=elem.options,one=elem.type=="select-one";
if(index<0){return null;
}for(var i=one?index:0,max=one?index+1:options.length;
i<max;
i++){var option=options[i];
if(option.selected){value=jQuery.browser.msie&&!option.attributes.value.specified?option.text:option.value;
if(one){return value;
}values.push(value);
}}return values;
}else{return(this[0].value||"").replace(/\r/g,"");
}}return undefined;
}if(value.constructor==Number){value+="";
}return this.each(function(){if(this.nodeType!=1){return ;
}if(value.constructor==Array&&/radio|checkbox/.test(this.type)){this.checked=(jQuery.inArray(this.value,value)>=0||jQuery.inArray(this.name,value)>=0);
}else{if(jQuery.nodeName(this,"select")){var values=jQuery.makeArray(value);
jQuery("option",this).each(function(){this.selected=(jQuery.inArray(this.value,values)>=0||jQuery.inArray(this.text,values)>=0);
});
if(!values.length){this.selectedIndex=-1;
}}else{this.value=value;
}}});
},html:function(value){return value==undefined?(this[0]?this[0].innerHTML:null):this.empty().append(value);
},replaceWith:function(value){return this.after(value).remove();
},eq:function(i){return this.slice(i,i+1);
},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments));
},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem);
}));
},andSelf:function(){return this.add(this.prevObject);
},data:function(key,value){var parts=key.split(".");
parts[1]=parts[1]?"."+parts[1]:"";
if(value===undefined){var data=this.triggerHandler("getData"+parts[1]+"!",[parts[0]]);
if(data===undefined&&this.length){data=jQuery.data(this[0],key);
}return data===undefined&&parts[1]?this.data(parts[0]):data;
}else{return this.trigger("setData"+parts[1]+"!",[parts[0],value]).each(function(){jQuery.data(this,key,value);
});
}},removeData:function(key){return this.each(function(){jQuery.removeData(this,key);
});
},domManip:function(args,table,reverse,callback){var clone=this.length>1,elems;
return this.each(function(){if(!elems){elems=jQuery.clean(args,this.ownerDocument);
if(reverse){elems.reverse();
}}var obj=this;
if(table&&jQuery.nodeName(this,"table")&&jQuery.nodeName(elems[0],"tr")){obj=this.getElementsByTagName("tbody")[0]||this.appendChild(this.ownerDocument.createElement("tbody"));
}var scripts=jQuery([]);
jQuery.each(elems,function(){var elem=clone?jQuery(this).clone(true)[0]:this;
if(jQuery.nodeName(elem,"script")){scripts=scripts.add(elem);
}else{if(elem.nodeType==1){scripts=scripts.add(jQuery("script",elem).remove());
}callback.call(obj,elem);
}});
scripts.each(evalScript);
});
}};
jQuery.fn.init.prototype=jQuery.fn;
function evalScript(i,elem){if(elem.src){jQuery.ajax({url:elem.src,async:false,dataType:"script"});
}else{jQuery.globalEval(elem.text||elem.textContent||elem.innerHTML||"");
}if(elem.parentNode){elem.parentNode.removeChild(elem);
}}function now(){return +new Date;
}jQuery.extend=jQuery.fn.extend=function(){var target=arguments[0]||{},i=1,length=arguments.length,deep=false,options;
if(target.constructor==Boolean){deep=target;
target=arguments[1]||{};
i=2;
}if(typeof target!="object"&&typeof target!="function"){target={};
}if(length==i){target=this;
--i;
}for(;
i<length;
i++){if((options=arguments[i])!=null){for(var name in options){var src=target[name],copy=options[name];
if(target===copy){continue;
}if(deep&&copy&&typeof copy=="object"&&!copy.nodeType){target[name]=jQuery.extend(deep,src||(copy.length!=null?[]:{}),copy);
}else{if(copy!==undefined){target[name]=copy;
}}}}}return target;
};
var expando="jQuery"+now(),uuid=0,windowData={},exclude=/z-?index|font-?weight|opacity|zoom|line-?height/i,defaultView=document.defaultView||{};
jQuery.extend({noConflict:function(deep){window.$=_$;
if(deep){window.jQuery=_jQuery;
}return jQuery;
},isFunction:function(fn){return !!fn&&typeof fn!="string"&&!fn.nodeName&&fn.constructor!=Array&&/^[\s[]?function/.test(fn+"");
},isXMLDoc:function(elem){return elem.documentElement&&!elem.body||elem.tagName&&elem.ownerDocument&&!elem.ownerDocument.body;
},globalEval:function(data){data=jQuery.trim(data);
if(data){var head=document.getElementsByTagName("head")[0]||document.documentElement,script=document.createElement("script");
script.type="text/javascript";
if(jQuery.browser.msie){script.text=data;
}else{script.appendChild(document.createTextNode(data));
}head.insertBefore(script,head.firstChild);
head.removeChild(script);
}},nodeName:function(elem,name){return elem.nodeName&&elem.nodeName.toUpperCase()==name.toUpperCase();
},cache:{},data:function(elem,name,data){elem=elem==window?windowData:elem;
var id=elem[expando];
if(!id){id=elem[expando]=++uuid;
}if(name&&!jQuery.cache[id]){jQuery.cache[id]={};
}if(data!==undefined){jQuery.cache[id][name]=data;
}return name?jQuery.cache[id][name]:id;
},removeData:function(elem,name){elem=elem==window?windowData:elem;
var id=elem[expando];
if(name){if(jQuery.cache[id]){delete jQuery.cache[id][name];
name="";
for(name in jQuery.cache[id]){break;
}if(!name){jQuery.removeData(elem);
}}}else{try{delete elem[expando];
}catch(e){if(elem.removeAttribute){elem.removeAttribute(expando);
}}delete jQuery.cache[id];
}},each:function(object,callback,args){var name,i=0,length=object.length;
if(args){if(length==undefined){for(name in object){if(callback.apply(object[name],args)===false){break;
}}}else{for(;
i<length;
){if(callback.apply(object[i++],args)===false){break;
}}}}else{if(length==undefined){for(name in object){if(callback.call(object[name],name,object[name])===false){break;
}}}else{for(var value=object[0];
i<length&&callback.call(value,i,value)!==false;
value=object[++i]){}}}return object;
},prop:function(elem,value,type,i,name){if(jQuery.isFunction(value)){value=value.call(elem,i);
}return value&&value.constructor==Number&&type=="curCSS"&&!exclude.test(name)?value+"px":value;
},className:{add:function(elem,classNames){jQuery.each((classNames||"").split(/\s+/),function(i,className){if(elem.nodeType==1&&!jQuery.className.has(elem.className,className)){elem.className+=(elem.className?" ":"")+className;
}});
},remove:function(elem,classNames){if(elem.nodeType==1){elem.className=classNames!=undefined?jQuery.grep(elem.className.split(/\s+/),function(className){return !jQuery.className.has(classNames,className);
}).join(" "):"";
}},has:function(elem,className){return jQuery.inArray(className,(elem.className||elem).toString().split(/\s+/))>-1;
}},swap:function(elem,options,callback){var old={};
for(var name in options){old[name]=elem.style[name];
elem.style[name]=options[name];
}callback.call(elem);
for(var name in options){elem.style[name]=old[name];
}},css:function(elem,name,force){if(name=="width"||name=="height"){var val,props={position:"absolute",visibility:"hidden",display:"block"},which=name=="width"?["Left","Right"]:["Top","Bottom"];
function getWH(){val=name=="width"?elem.offsetWidth:elem.offsetHeight;
var padding=0,border=0;
jQuery.each(which,function(){padding+=parseFloat(jQuery.curCSS(elem,"padding"+this,true))||0;
border+=parseFloat(jQuery.curCSS(elem,"border"+this+"Width",true))||0;
});
val-=Math.round(padding+border);
}if(jQuery(elem).is(":visible")){getWH();
}else{jQuery.swap(elem,props,getWH);
}return Math.max(0,val);
}return jQuery.curCSS(elem,name,force);
},curCSS:function(elem,name,force){var ret,style=elem.style;
function color(elem){if(!jQuery.browser.safari){return false;
}var ret=defaultView.getComputedStyle(elem,null);
return !ret||ret.getPropertyValue("color")=="";
}if(name=="opacity"&&jQuery.browser.msie){ret=jQuery.attr(style,"opacity");
return ret==""?"1":ret;
}if(jQuery.browser.opera&&name=="display"){var save=style.outline;
style.outline="0 solid black";
style.outline=save;
}if(name.match(/float/i)){name=styleFloat;
}if(!force&&style&&style[name]){ret=style[name];
}else{if(defaultView.getComputedStyle){if(name.match(/float/i)){name="float";
}name=name.replace(/([A-Z])/g,"-$1").toLowerCase();
var computedStyle=defaultView.getComputedStyle(elem,null);
if(computedStyle&&!color(elem)){ret=computedStyle.getPropertyValue(name);
}else{var swap=[],stack=[],a=elem,i=0;
for(;
a&&color(a);
a=a.parentNode){stack.unshift(a);
}for(;
i<stack.length;
i++){if(color(stack[i])){swap[i]=stack[i].style.display;
stack[i].style.display="block";
}}ret=name=="display"&&swap[stack.length-1]!=null?"none":(computedStyle&&computedStyle.getPropertyValue(name))||"";
for(i=0;
i<swap.length;
i++){if(swap[i]!=null){stack[i].style.display=swap[i];
}}}if(name=="opacity"&&ret==""){ret="1";
}}else{if(elem.currentStyle){var camelCase=name.replace(/\-(\w)/g,function(all,letter){return letter.toUpperCase();
});
ret=elem.currentStyle[name]||elem.currentStyle[camelCase];
if(!/^\d+(px)?$/i.test(ret)&&/^\d/.test(ret)){var left=style.left,rsLeft=elem.runtimeStyle.left;
elem.runtimeStyle.left=elem.currentStyle.left;
style.left=ret||0;
ret=style.pixelLeft+"px";
style.left=left;
elem.runtimeStyle.left=rsLeft;
}}}}return ret;
},clean:function(elems,context){var ret=[];
context=context||document;
if(typeof context.createElement=="undefined"){context=context.ownerDocument||context[0]&&context[0].ownerDocument||document;
}jQuery.each(elems,function(i,elem){if(!elem){return ;
}if(elem.constructor==Number){elem+="";
}if(typeof elem=="string"){elem=elem.replace(/(<(\w+)[^>]*?)\/>/g,function(all,front,tag){return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?all:front+"></"+tag+">";
});
var tags=jQuery.trim(elem).toLowerCase(),div=context.createElement("div");
var wrap=!tags.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!tags.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||tags.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!tags.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!tags.indexOf("<td")||!tags.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!tags.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||jQuery.browser.msie&&[1,"div<div>","</div>"]||[0,"",""];
div.innerHTML=wrap[1]+elem+wrap[2];
while(wrap[0]--){div=div.lastChild;
}if(jQuery.browser.msie){var tbody=!tags.indexOf("<table")&&tags.indexOf("<tbody")<0?div.firstChild&&div.firstChild.childNodes:wrap[1]=="<table>"&&tags.indexOf("<tbody")<0?div.childNodes:[];
for(var j=tbody.length-1;
j>=0;
--j){if(jQuery.nodeName(tbody[j],"tbody")&&!tbody[j].childNodes.length){tbody[j].parentNode.removeChild(tbody[j]);
}}if(/^\s/.test(elem)){div.insertBefore(context.createTextNode(elem.match(/^\s*/)[0]),div.firstChild);
}}elem=jQuery.makeArray(div.childNodes);
}if(elem.length===0&&(!jQuery.nodeName(elem,"form")&&!jQuery.nodeName(elem,"select"))){return ;
}if(elem[0]==undefined||jQuery.nodeName(elem,"form")||elem.options){ret.push(elem);
}else{ret=jQuery.merge(ret,elem);
}});
return ret;
},attr:function(elem,name,value){if(!elem||elem.nodeType==3||elem.nodeType==8){return undefined;
}var notxml=!jQuery.isXMLDoc(elem),set=value!==undefined,msie=jQuery.browser.msie;
name=notxml&&jQuery.props[name]||name;
if(elem.tagName){var special=/href|src|style/.test(name);
if(name=="selected"&&jQuery.browser.safari){elem.parentNode.selectedIndex;
}if(name in elem&&notxml&&!special){if(set){if(name=="type"&&jQuery.nodeName(elem,"input")&&elem.parentNode){throw"type property can't be changed";
}elem[name]=value;
}if(jQuery.nodeName(elem,"form")&&elem.getAttributeNode(name)){return elem.getAttributeNode(name).nodeValue;
}return elem[name];
}if(msie&&notxml&&name=="style"){return jQuery.attr(elem.style,"cssText",value);
}if(set){elem.setAttribute(name,""+value);
}var attr=msie&&notxml&&special?elem.getAttribute(name,2):elem.getAttribute(name);
return attr===null?undefined:attr;
}if(msie&&name=="opacity"){if(set){elem.zoom=1;
elem.filter=(elem.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(value)+""=="NaN"?"":"alpha(opacity="+value*100+")");
}return elem.filter&&elem.filter.indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity=([^)]*)/)[1])/100)+"":"";
}name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase();
});
if(set){elem[name]=value;
}return elem[name];
},trim:function(text){return(text||"").replace(/^\s+|\s+$/g,"");
},makeArray:function(array){var ret=[];
if(array!=null){var i=array.length;
if(i==null||array.split||array.setInterval||array.call){ret[0]=array;
}else{while(i){ret[--i]=array[i];
}}}return ret;
},inArray:function(elem,array){for(var i=0,length=array.length;
i<length;
i++){if(array[i]===elem){return i;
}}return -1;
},merge:function(first,second){var i=0,elem,pos=first.length;
if(jQuery.browser.msie){while(elem=second[i++]){if(elem.nodeType!=8){first[pos++]=elem;
}}}else{while(elem=second[i++]){first[pos++]=elem;
}}return first;
},unique:function(array){var ret=[],done={};
try{for(var i=0,length=array.length;
i<length;
i++){var id=jQuery.data(array[i]);
if(!done[id]){done[id]=true;
ret.push(array[i]);
}}}catch(e){ret=array;
}return ret;
},grep:function(elems,callback,inv){var ret=[];
for(var i=0,length=elems.length;
i<length;
i++){if(!inv!=!callback(elems[i],i)){ret.push(elems[i]);
}}return ret;
},map:function(elems,callback){var ret=[];
for(var i=0,length=elems.length;
i<length;
i++){var value=callback(elems[i],i);
if(value!=null){ret[ret.length]=value;
}}return ret.concat.apply([],ret);
}});
var userAgent=navigator.userAgent.toLowerCase();
jQuery.browser={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],safari:/webkit/.test(userAgent),opera:/opera/.test(userAgent),msie:/msie/.test(userAgent)&&!/opera/.test(userAgent),mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)};
var styleFloat=jQuery.browser.msie?"styleFloat":"cssFloat";
jQuery.extend({boxModel:!jQuery.browser.msie||document.compatMode=="CSS1Compat",props:{"for":"htmlFor","class":"className","float":styleFloat,cssFloat:styleFloat,styleFloat:styleFloat,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing"}});
jQuery.each({parent:function(elem){return elem.parentNode;
},parents:function(elem){return jQuery.dir(elem,"parentNode");
},next:function(elem){return jQuery.nth(elem,2,"nextSibling");
},prev:function(elem){return jQuery.nth(elem,2,"previousSibling");
},nextAll:function(elem){return jQuery.dir(elem,"nextSibling");
},prevAll:function(elem){return jQuery.dir(elem,"previousSibling");
},siblings:function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);
},children:function(elem){return jQuery.sibling(elem.firstChild);
},contents:function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);
}},function(name,fn){jQuery.fn[name]=function(selector){var ret=jQuery.map(this,fn);
if(selector&&typeof selector=="string"){ret=jQuery.multiFilter(selector,ret);
}return this.pushStack(jQuery.unique(ret));
};
});
jQuery.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(name,original){jQuery.fn[name]=function(){var args=arguments;
return this.each(function(){for(var i=0,length=args.length;
i<length;
i++){jQuery(args[i])[original](this);
}});
};
});
jQuery.each({removeAttr:function(name){jQuery.attr(this,name,"");
if(this.nodeType==1){this.removeAttribute(name);
}},addClass:function(classNames){jQuery.className.add(this,classNames);
},removeClass:function(classNames){jQuery.className.remove(this,classNames);
},toggleClass:function(classNames){jQuery.className[jQuery.className.has(this,classNames)?"remove":"add"](this,classNames);
},remove:function(selector){if(!selector||jQuery.filter(selector,[this]).r.length){jQuery("*",this).add(this).each(function(){jQuery.event.remove(this);
jQuery.removeData(this);
});
if(this.parentNode){this.parentNode.removeChild(this);
}}},empty:function(){jQuery(">*",this).remove();
while(this.firstChild){this.removeChild(this.firstChild);
}}},function(name,fn){jQuery.fn[name]=function(){return this.each(fn,arguments);
};
});
jQuery.each(["Height","Width"],function(i,name){var type=name.toLowerCase();
jQuery.fn[type]=function(size){return this[0]==window?jQuery.browser.opera&&document.body["client"+name]||jQuery.browser.safari&&window["inner"+name]||document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(Math.max(document.body["scroll"+name],document.documentElement["scroll"+name]),Math.max(document.body["offset"+name],document.documentElement["offset"+name])):size==undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,size.constructor==String?size:size+"px");
};
});
function num(elem,prop){return elem[0]&&parseInt(jQuery.curCSS(elem[0],prop,true),10)||0;
}var chars=jQuery.browser.safari&&parseInt(jQuery.browser.version)<417?"(?:[\\w*_-]|\\\\.)":"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",quickChild=new RegExp("^>\\s*("+chars+"+)"),quickID=new RegExp("^("+chars+"+)(#)("+chars+"+)"),quickClass=new RegExp("^([#.]?)("+chars+"*)");
jQuery.extend({expr:{"":function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);
},"#":function(a,i,m){return a.getAttribute("id")==m[2];
},":":{lt:function(a,i,m){return i<m[3]-0;
},gt:function(a,i,m){return i>m[3]-0;
},nth:function(a,i,m){return m[3]-0==i;
},eq:function(a,i,m){return m[3]-0==i;
},first:function(a,i){return i==0;
},last:function(a,i,m,r){return i==r.length-1;
},even:function(a,i){return i%2==0;
},odd:function(a,i){return i%2;
},"first-child":function(a){return a.parentNode.getElementsByTagName("*")[0]==a;
},"last-child":function(a){return jQuery.nth(a.parentNode.lastChild,1,"previousSibling")==a;
},"only-child":function(a){return !jQuery.nth(a.parentNode.lastChild,2,"previousSibling");
},parent:function(a){return a.firstChild;
},empty:function(a){return !a.firstChild;
},contains:function(a,i,m){return(a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;
},visible:function(a){return"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden";
},hidden:function(a){return"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden";
},enabled:function(a){return !a.disabled;
},disabled:function(a){return a.disabled;
},checked:function(a){return a.checked;
},selected:function(a){return a.selected||jQuery.attr(a,"selected");
},text:function(a){return"text"==a.type;
},radio:function(a){return"radio"==a.type;
},checkbox:function(a){return"checkbox"==a.type;
},file:function(a){return"file"==a.type;
},password:function(a){return"password"==a.type;
},submit:function(a){return"submit"==a.type;
},image:function(a){return"image"==a.type;
},reset:function(a){return"reset"==a.type;
},button:function(a){return"button"==a.type||jQuery.nodeName(a,"button");
},input:function(a){return/input|select|textarea|button/i.test(a.nodeName);
},has:function(a,i,m){return jQuery.find(m[3],a).length;
},header:function(a){return/h\d/i.test(a.nodeName);
},animated:function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;
}).length;
}}},parse:[/^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,new RegExp("^([:.#]*)("+chars+"+)")],multiFilter:function(expr,elems,not){var old,cur=[];
while(expr&&expr!=old){old=expr;
var f=jQuery.filter(expr,elems,not);
expr=f.t.replace(/^\s*,\s*/,"");
cur=not?elems=f.r:jQuery.merge(cur,f.r);
}return cur;
},find:function(t,context){if(typeof t!="string"){return[t];
}if(context&&context.nodeType!=1&&context.nodeType!=9){return[];
}context=context||document;
var ret=[context],done=[],last,nodeName;
while(t&&last!=t){var r=[];
last=t;
t=jQuery.trim(t);
var foundToken=false,re=quickChild,m=re.exec(t);
if(m){nodeName=m[1].toUpperCase();
for(var i=0;
ret[i];
i++){for(var c=ret[i].firstChild;
c;
c=c.nextSibling){if(c.nodeType==1&&(nodeName=="*"||c.nodeName.toUpperCase()==nodeName)){r.push(c);
}}}ret=r;
t=t.replace(re,"");
if(t.indexOf(" ")==0){continue;
}foundToken=true;
}else{re=/^([>+~])\s*(\w*)/i;
if((m=re.exec(t))!=null){r=[];
var merge={};
nodeName=m[2].toUpperCase();
m=m[1];
for(var j=0,rl=ret.length;
j<rl;
j++){var n=m=="~"||m=="+"?ret[j].nextSibling:ret[j].firstChild;
for(;
n;
n=n.nextSibling){if(n.nodeType==1){var id=jQuery.data(n);
if(m=="~"&&merge[id]){break;
}if(!nodeName||n.nodeName.toUpperCase()==nodeName){if(m=="~"){merge[id]=true;
}r.push(n);
}if(m=="+"){break;
}}}}ret=r;
t=jQuery.trim(t.replace(re,""));
foundToken=true;
}}if(t&&!foundToken){if(!t.indexOf(",")){if(context==ret[0]){ret.shift();
}done=jQuery.merge(done,ret);
r=ret=[context];
t=" "+t.substr(1,t.length);
}else{var re2=quickID;
var m=re2.exec(t);
if(m){m=[0,m[2],m[3],m[1]];
}else{re2=quickClass;
m=re2.exec(t);
}m[2]=m[2].replace(/\\/g,"");
var elem=ret[ret.length-1];
if(m[1]=="#"&&elem&&elem.getElementById&&!jQuery.isXMLDoc(elem)){var oid=elem.getElementById(m[2]);
if((jQuery.browser.msie||jQuery.browser.opera)&&oid&&typeof oid.id=="string"&&oid.id!=m[2]){oid=jQuery('[@id="'+m[2]+'"]',elem)[0];
}ret=r=oid&&(!m[3]||jQuery.nodeName(oid,m[3]))?[oid]:[];
}else{for(var i=0;
ret[i];
i++){var tag=m[1]=="#"&&m[3]?m[3]:m[1]!=""||m[0]==""?"*":m[2];
if(tag=="*"&&ret[i].nodeName.toLowerCase()=="object"){tag="param";
}r=jQuery.merge(r,ret[i].getElementsByTagName(tag));
}if(m[1]=="."){r=jQuery.classFilter(r,m[2]);
}if(m[1]=="#"){var tmp=[];
for(var i=0;
r[i];
i++){if(r[i].getAttribute("id")==m[2]){tmp=[r[i]];
break;
}}r=tmp;
}ret=r;
}t=t.replace(re2,"");
}}if(t){var val=jQuery.filter(t,r);
ret=r=val.r;
t=jQuery.trim(val.t);
}}if(t){ret=[];
}if(ret&&context==ret[0]){ret.shift();
}done=jQuery.merge(done,ret);
return done;
},classFilter:function(r,m,not){m=" "+m+" ";
var tmp=[];
for(var i=0;
r[i];
i++){var pass=(" "+r[i].className+" ").indexOf(m)>=0;
if(!not&&pass||not&&!pass){tmp.push(r[i]);
}}return tmp;
},filter:function(t,r,not){var last;
while(t&&t!=last){last=t;
var p=jQuery.parse,m;
for(var i=0;
p[i];
i++){m=p[i].exec(t);
if(m){t=t.substring(m[0].length);
m[2]=m[2].replace(/\\/g,"");
break;
}}if(!m){break;
}if(m[1]==":"&&m[2]=="not"){r=isSimple.test(m[3])?jQuery.filter(m[3],r,true).r:jQuery(r).not(m[3]);
}else{if(m[1]=="."){r=jQuery.classFilter(r,m[2],not);
}else{if(m[1]=="["){var tmp=[],type=m[3];
for(var i=0,rl=r.length;
i<rl;
i++){var a=r[i],z=a[jQuery.props[m[2]]||m[2]];
if(z==null||/href|src|selected/.test(m[2])){z=jQuery.attr(a,m[2])||"";
}if((type==""&&!!z||type=="="&&z==m[5]||type=="!="&&z!=m[5]||type=="^="&&z&&!z.indexOf(m[5])||type=="$="&&z.substr(z.length-m[5].length)==m[5]||(type=="*="||type=="~=")&&z.indexOf(m[5])>=0)^not){tmp.push(a);
}}r=tmp;
}else{if(m[1]==":"&&m[2]=="nth-child"){var merge={},tmp=[],test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(m[3]=="even"&&"2n"||m[3]=="odd"&&"2n+1"||!/\D/.test(m[3])&&"0n+"+m[3]||m[3]),first=(test[1]+(test[2]||1))-0,last=test[3]-0;
for(var i=0,rl=r.length;
i<rl;
i++){var node=r[i],parentNode=node.parentNode,id=jQuery.data(parentNode);
if(!merge[id]){var c=1;
for(var n=parentNode.firstChild;
n;
n=n.nextSibling){if(n.nodeType==1){n.nodeIndex=c++;
}}merge[id]=true;
}var add=false;
if(first==0){if(node.nodeIndex==last){add=true;
}}else{if((node.nodeIndex-last)%first==0&&(node.nodeIndex-last)/first>=0){add=true;
}}if(add^not){tmp.push(node);
}}r=tmp;
}else{var fn=jQuery.expr[m[1]];
if(typeof fn=="object"){fn=fn[m[2]];
}if(typeof fn=="string"){fn=eval("false||function(a,i){return "+fn+";}");
}r=jQuery.grep(r,function(elem,i){return fn(elem,i,m,r);
},not);
}}}}}return{r:r,t:t};
},dir:function(elem,dir){var matched=[],cur=elem[dir];
while(cur&&cur!=document){if(cur.nodeType==1){matched.push(cur);
}cur=cur[dir];
}return matched;
},nth:function(cur,result,dir,elem){result=result||1;
var num=0;
for(;
cur;
cur=cur[dir]){if(cur.nodeType==1&&++num==result){break;
}}return cur;
},sibling:function(n,elem){var r=[];
for(;
n;
n=n.nextSibling){if(n.nodeType==1&&n!=elem){r.push(n);
}}return r;
}});
jQuery.event={add:function(elem,types,handler,data){if(elem.nodeType==3||elem.nodeType==8){return ;
}if(jQuery.browser.msie&&elem.setInterval){elem=window;
}if(!handler.guid){handler.guid=this.guid++;
}if(data!=undefined){var fn=handler;
handler=this.proxy(fn,function(){return fn.apply(this,arguments);
});
handler.data=data;
}var events=jQuery.data(elem,"events")||jQuery.data(elem,"events",{}),handle=jQuery.data(elem,"handle")||jQuery.data(elem,"handle",function(){if(typeof jQuery!="undefined"&&!jQuery.event.triggered){return jQuery.event.handle.apply(arguments.callee.elem,arguments);
}});
handle.elem=elem;
jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");
type=parts[0];
handler.type=parts[1];
var handlers=events[type];
if(!handlers){handlers=events[type]={};
if(!jQuery.event.special[type]||jQuery.event.special[type].setup.call(elem)===false){if(elem.addEventListener){elem.addEventListener(type,handle,false);
}else{if(elem.attachEvent){elem.attachEvent("on"+type,handle);
}}}}handlers[handler.guid]=handler;
jQuery.event.global[type]=true;
});
elem=null;
},guid:1,global:{},remove:function(elem,types,handler){if(elem.nodeType==3||elem.nodeType==8){return ;
}var events=jQuery.data(elem,"events"),ret,index;
if(events){if(types==undefined||(typeof types=="string"&&types.charAt(0)==".")){for(var type in events){this.remove(elem,type+(types||""));
}}else{if(types.type){handler=types.handler;
types=types.type;
}jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");
type=parts[0];
if(events[type]){if(handler){delete events[type][handler.guid];
}else{for(handler in events[type]){if(!parts[1]||events[type][handler].type==parts[1]){delete events[type][handler];
}}}for(ret in events[type]){break;
}if(!ret){if(!jQuery.event.special[type]||jQuery.event.special[type].teardown.call(elem)===false){if(elem.removeEventListener){elem.removeEventListener(type,jQuery.data(elem,"handle"),false);
}else{if(elem.detachEvent){elem.detachEvent("on"+type,jQuery.data(elem,"handle"));
}}}ret=null;
delete events[type];
}}});
}for(ret in events){break;
}if(!ret){var handle=jQuery.data(elem,"handle");
if(handle){handle.elem=null;
}jQuery.removeData(elem,"events");
jQuery.removeData(elem,"handle");
}}},trigger:function(type,data,elem,donative,extra){data=jQuery.makeArray(data);
if(type.indexOf("!")>=0){type=type.slice(0,-1);
var exclusive=true;
}if(!elem){if(this.global[type]){jQuery("*").add([window,document]).trigger(type,data);
}}else{if(elem.nodeType==3||elem.nodeType==8){return undefined;
}var val,ret,fn=jQuery.isFunction(elem[type]||null),event=!data[0]||!data[0].preventDefault;
if(event){data.unshift({type:type,target:elem,preventDefault:function(){},stopPropagation:function(){},timeStamp:now()});
data[0][expando]=true;
}data[0].type=type;
if(exclusive){data[0].exclusive=true;
}var handle=jQuery.data(elem,"handle");
if(handle){val=handle.apply(elem,data);
}if((!fn||(jQuery.nodeName(elem,"a")&&type=="click"))&&elem["on"+type]&&elem["on"+type].apply(elem,data)===false){val=false;
}if(event){data.shift();
}if(extra&&jQuery.isFunction(extra)){ret=extra.apply(elem,val==null?data:data.concat(val));
if(ret!==undefined){val=ret;
}}if(fn&&donative!==false&&val!==false&&!(jQuery.nodeName(elem,"a")&&type=="click")){this.triggered=true;
try{elem[type]();
}catch(e){}}this.triggered=false;
}return val;
},handle:function(event){var val,ret,namespace,all,handlers;
event=arguments[0]=jQuery.event.fix(event||window.event);
namespace=event.type.split(".");
event.type=namespace[0];
namespace=namespace[1];
all=!namespace&&!event.exclusive;
handlers=(jQuery.data(this,"events")||{})[event.type];
for(var j in handlers){var handler=handlers[j];
if(all||handler.type==namespace){event.handler=handler;
event.data=handler.data;
ret=handler.apply(this,arguments);
if(val!==false){val=ret;
}if(ret===false){event.preventDefault();
event.stopPropagation();
}}}return val;
},fix:function(event){if(event[expando]==true){return event;
}var originalEvent=event;
event={originalEvent:originalEvent};
var props="altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view wheelDelta which".split(" ");
for(var i=props.length;
i;
i--){event[props[i]]=originalEvent[props[i]];
}event[expando]=true;
event.preventDefault=function(){if(originalEvent.preventDefault){originalEvent.preventDefault();
}originalEvent.returnValue=false;
};
event.stopPropagation=function(){if(originalEvent.stopPropagation){originalEvent.stopPropagation();
}originalEvent.cancelBubble=true;
};
event.timeStamp=event.timeStamp||now();
if(!event.target){event.target=event.srcElement||document;
}if(event.target.nodeType==3){event.target=event.target.parentNode;
}if(!event.relatedTarget&&event.fromElement){event.relatedTarget=event.fromElement==event.target?event.toElement:event.fromElement;
}if(event.pageX==null&&event.clientX!=null){var doc=document.documentElement,body=document.body;
event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc.clientLeft||0);
event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc.clientTop||0);
}if(!event.which&&((event.charCode||event.charCode===0)?event.charCode:event.keyCode)){event.which=event.charCode||event.keyCode;
}if(!event.metaKey&&event.ctrlKey){event.metaKey=event.ctrlKey;
}if(!event.which&&event.button){event.which=(event.button&1?1:(event.button&2?3:(event.button&4?2:0)));
}return event;
},proxy:function(fn,proxy){proxy.guid=fn.guid=fn.guid||proxy.guid||this.guid++;
return proxy;
},special:{ready:{setup:function(){bindReady();
return ;
},teardown:function(){return ;
}},mouseenter:{setup:function(){if(jQuery.browser.msie){return false;
}jQuery(this).bind("mouseover",jQuery.event.special.mouseenter.handler);
return true;
},teardown:function(){if(jQuery.browser.msie){return false;
}jQuery(this).unbind("mouseover",jQuery.event.special.mouseenter.handler);
return true;
},handler:function(event){if(withinElement(event,this)){return true;
}event.type="mouseenter";
return jQuery.event.handle.apply(this,arguments);
}},mouseleave:{setup:function(){if(jQuery.browser.msie){return false;
}jQuery(this).bind("mouseout",jQuery.event.special.mouseleave.handler);
return true;
},teardown:function(){if(jQuery.browser.msie){return false;
}jQuery(this).unbind("mouseout",jQuery.event.special.mouseleave.handler);
return true;
},handler:function(event){if(withinElement(event,this)){return true;
}event.type="mouseleave";
return jQuery.event.handle.apply(this,arguments);
}}}};
jQuery.fn.extend({bind:function(type,data,fn){return type=="unload"?this.one(type,data,fn):this.each(function(){jQuery.event.add(this,type,fn||data,fn&&data);
});
},one:function(type,data,fn){var one=jQuery.event.proxy(fn||data,function(event){jQuery(this).unbind(event,one);
return(fn||data).apply(this,arguments);
});
return this.each(function(){jQuery.event.add(this,type,one,fn&&data);
});
},unbind:function(type,fn){return this.each(function(){jQuery.event.remove(this,type,fn);
});
},trigger:function(type,data,fn){return this.each(function(){jQuery.event.trigger(type,data,this,true,fn);
});
},triggerHandler:function(type,data,fn){return this[0]&&jQuery.event.trigger(type,data,this[0],false,fn);
},toggle:function(fn){var args=arguments,i=1;
while(i<args.length){jQuery.event.proxy(fn,args[i++]);
}return this.click(jQuery.event.proxy(fn,function(event){this.lastToggle=(this.lastToggle||0)%i;
event.preventDefault();
return args[this.lastToggle++].apply(this,arguments)||false;
}));
},hover:function(fnOver,fnOut){return this.bind("mouseenter",fnOver).bind("mouseleave",fnOut);
},ready:function(fn){bindReady();
if(jQuery.isReady){fn.call(document,jQuery);
}else{jQuery.readyList.push(function(){return fn.call(this,jQuery);
});
}return this;
}});
jQuery.extend({isReady:false,readyList:[],ready:function(){if(!jQuery.isReady){jQuery.isReady=true;
if(jQuery.readyList){jQuery.each(jQuery.readyList,function(){this.call(document);
});
jQuery.readyList=null;
}jQuery(document).triggerHandler("ready");
}}});
var readyBound=false;
function bindReady(){if(readyBound){return ;
}readyBound=true;
if(document.addEventListener&&!jQuery.browser.opera){document.addEventListener("DOMContentLoaded",jQuery.ready,false);
}if(jQuery.browser.msie&&window==top){(function(){if(jQuery.isReady){return ;
}try{document.documentElement.doScroll("left");
}catch(error){setTimeout(arguments.callee,0);
return ;
}jQuery.ready();
})();
}if(jQuery.browser.opera){document.addEventListener("DOMContentLoaded",function(){if(jQuery.isReady){return ;
}for(var i=0;
i<document.styleSheets.length;
i++){if(document.styleSheets[i].disabled){setTimeout(arguments.callee,0);
return ;
}}jQuery.ready();
},false);
}if(jQuery.browser.safari){var numStyles;
(function(){if(jQuery.isReady){return ;
}if(document.readyState!="loaded"&&document.readyState!="complete"){setTimeout(arguments.callee,0);
return ;
}if(numStyles===undefined){numStyles=jQuery("style, link[rel=stylesheet]").length;
}if(document.styleSheets.length!=numStyles){setTimeout(arguments.callee,0);
return ;
}jQuery.ready();
})();
}jQuery.event.add(window,"load",jQuery.ready);
}jQuery.each(("blur,focus,load,resize,scroll,unload,click,dblclick,mousedown,mouseup,mousemove,mouseover,mouseout,change,select,submit,keydown,keypress,keyup,error").split(","),function(i,name){jQuery.fn[name]=function(fn){return fn?this.bind(name,fn):this.trigger(name);
};
});
var withinElement=function(event,elem){var parent=event.relatedTarget;
while(parent&&parent!=elem){try{parent=parent.parentNode;
}catch(error){parent=elem;
}}return parent==elem;
};
jQuery(window).bind("unload",function(){jQuery("*").add(document).unbind();
});
jQuery.fn.extend({_load:jQuery.fn.load,load:function(url,params,callback){if(typeof url!="string"){return this._load(url);
}var off=url.indexOf(" ");
if(off>=0){var selector=url.slice(off,url.length);
url=url.slice(0,off);
}callback=callback||function(){};
var type="GET";
if(params){if(jQuery.isFunction(params)){callback=params;
params=null;
}else{params=jQuery.param(params);
type="POST";
}}var self=this;
jQuery.ajax({url:url,type:type,dataType:"html",data:params,complete:function(res,status){if(status=="success"||status=="notmodified"){self.html(selector?jQuery("<div/>").append(res.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(selector):res.responseText);
}self.each(callback,[res.responseText,status,res]);
}});
return this;
},serialize:function(){return jQuery.param(this.serializeArray());
},serializeArray:function(){return this.map(function(){return jQuery.nodeName(this,"form")?jQuery.makeArray(this.elements):this;
}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password/i.test(this.type));
}).map(function(i,elem){var val=jQuery(this).val();
return val==null?null:val.constructor==Array?jQuery.map(val,function(val,i){return{name:elem.name,value:val};
}):{name:elem.name,value:val};
}).get();
}});
jQuery.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(i,o){jQuery.fn[o]=function(f){return this.bind(o,f);
};
});
var jsc=now();
jQuery.extend({get:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;
data=null;
}return jQuery.ajax({type:"GET",url:url,data:data,success:callback,dataType:type});
},getScript:function(url,callback){return jQuery.get(url,null,callback,"script");
},getJSON:function(url,data,callback){return jQuery.get(url,data,callback,"json");
},post:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;
data={};
}return jQuery.ajax({type:"POST",url:url,data:data,success:callback,dataType:type});
},ajaxSetup:function(settings){jQuery.extend(jQuery.ajaxSettings,settings);
},ajaxSettings:{url:location.href,global:true,type:"GET",timeout:0,contentType:"application/x-www-form-urlencoded",processData:true,async:true,data:null,username:null,password:null,accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(s){s=jQuery.extend(true,s,jQuery.extend(true,{},jQuery.ajaxSettings,s));
var jsonp,jsre=/=\?(&|$)/g,status,data,type=s.type.toUpperCase();
if(s.data&&s.processData&&typeof s.data!="string"){s.data=jQuery.param(s.data);
}if(s.dataType=="jsonp"){if(type=="GET"){if(!s.url.match(jsre)){s.url+=(s.url.match(/\?/)?"&":"?")+(s.jsonp||"callback")+"=?";
}}else{if(!s.data||!s.data.match(jsre)){s.data=(s.data?s.data+"&":"")+(s.jsonp||"callback")+"=?";
}}s.dataType="json";
}if(s.dataType=="json"&&(s.data&&s.data.match(jsre)||s.url.match(jsre))){jsonp="jsonp"+jsc++;
if(s.data){s.data=(s.data+"").replace(jsre,"="+jsonp+"$1");
}s.url=s.url.replace(jsre,"="+jsonp+"$1");
s.dataType="script";
window[jsonp]=function(tmp){data=tmp;
success();
complete();
window[jsonp]=undefined;
try{delete window[jsonp];
}catch(e){}if(head){head.removeChild(script);
}};
}if(s.dataType=="script"&&s.cache==null){s.cache=false;
}if(s.cache===false&&type=="GET"){var ts=now();
var ret=s.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+ts+"$2");
s.url=ret+((ret==s.url)?(s.url.match(/\?/)?"&":"?")+"_="+ts:"");
}if(s.data&&type=="GET"){s.url+=(s.url.match(/\?/)?"&":"?")+s.data;
s.data=null;
}if(s.global&&!jQuery.active++){jQuery.event.trigger("ajaxStart");
}var remote=/^(?:\w+:)?\/\/([^\/?#]+)/;
if(s.dataType=="script"&&type=="GET"&&remote.test(s.url)&&remote.exec(s.url)[1]!=location.host){var head=document.getElementsByTagName("head")[0];
var script=document.createElement("script");
script.src=s.url;
if(s.scriptCharset){script.charset=s.scriptCharset;
}if(!jsonp){var done=false;
script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;
success();
complete();
head.removeChild(script);
}};
}head.appendChild(script);
return undefined;
}var requestDone=false;
var xhr=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();
if(s.username){xhr.open(type,s.url,s.async,s.username,s.password);
}else{xhr.open(type,s.url,s.async);
}try{if(s.data){xhr.setRequestHeader("Content-Type",s.contentType);
}if(s.ifModified){xhr.setRequestHeader("If-Modified-Since",jQuery.lastModified[s.url]||"Thu, 01 Jan 1970 00:00:00 GMT");
}xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");
xhr.setRequestHeader("Accept",s.dataType&&s.accepts[s.dataType]?s.accepts[s.dataType]+", */*":s.accepts._default);
}catch(e){}if(s.beforeSend&&s.beforeSend(xhr,s)===false){s.global&&jQuery.active--;
xhr.abort();
return false;
}if(s.global){jQuery.event.trigger("ajaxSend",[xhr,s]);
}var onreadystatechange=function(isTimeout){if(!requestDone&&xhr&&(xhr.readyState==4||isTimeout=="timeout")){requestDone=true;
if(ival){clearInterval(ival);
ival=null;
}status=isTimeout=="timeout"&&"timeout"||!jQuery.httpSuccess(xhr)&&"error"||s.ifModified&&jQuery.httpNotModified(xhr,s.url)&&"notmodified"||"success";
if(status=="success"){try{data=jQuery.httpData(xhr,s.dataType,s.dataFilter);
}catch(e){status="parsererror";
}}if(status=="success"){var modRes;
try{modRes=xhr.getResponseHeader("Last-Modified");
}catch(e){}if(s.ifModified&&modRes){jQuery.lastModified[s.url]=modRes;
}if(!jsonp){success();
}}else{jQuery.handleError(s,xhr,status);
}complete();
if(s.async){xhr=null;
}}};
if(s.async){var ival=setInterval(onreadystatechange,13);
if(s.timeout>0){setTimeout(function(){if(xhr){xhr.abort();
if(!requestDone){onreadystatechange("timeout");
}}},s.timeout);
}}try{xhr.send(s.data);
}catch(e){jQuery.handleError(s,xhr,null,e);
}if(!s.async){onreadystatechange();
}function success(){if(s.success){s.success(data,status);
}if(s.global){jQuery.event.trigger("ajaxSuccess",[xhr,s]);
}}function complete(){if(s.complete){s.complete(xhr,status);
}if(s.global){jQuery.event.trigger("ajaxComplete",[xhr,s]);
}if(s.global&&!--jQuery.active){jQuery.event.trigger("ajaxStop");
}}return xhr;
},handleError:function(s,xhr,status,e){if(s.error){s.error(xhr,status,e);
}if(s.global){jQuery.event.trigger("ajaxError",[xhr,s,e]);
}},active:0,httpSuccess:function(xhr){try{return !xhr.status&&location.protocol=="file:"||(xhr.status>=200&&xhr.status<300)||xhr.status==304||xhr.status==1223||jQuery.browser.safari&&xhr.status==undefined;
}catch(e){}return false;
},httpNotModified:function(xhr,url){try{var xhrRes=xhr.getResponseHeader("Last-Modified");
return xhr.status==304||xhrRes==jQuery.lastModified[url]||jQuery.browser.safari&&xhr.status==undefined;
}catch(e){}return false;
},httpData:function(xhr,type,filter){var ct=xhr.getResponseHeader("content-type"),xml=type=="xml"||!type&&ct&&ct.indexOf("xml")>=0,data=xml?xhr.responseXML:xhr.responseText;
if(xml&&data.documentElement.tagName=="parsererror"){throw"parsererror";
}if(filter){data=filter(data,type);
}if(type=="script"){jQuery.globalEval(data);
}if(type=="json"){data=eval("("+data+")");
}return data;
},param:function(a){var s=[];
if(a.constructor==Array||a.jquery){jQuery.each(a,function(){s.push(encodeURIComponent(this.name)+"="+encodeURIComponent(this.value));
});
}else{for(var j in a){if(a[j]&&a[j].constructor==Array){jQuery.each(a[j],function(){s.push(encodeURIComponent(j)+"="+encodeURIComponent(this));
});
}else{s.push(encodeURIComponent(j)+"="+encodeURIComponent(jQuery.isFunction(a[j])?a[j]():a[j]));
}}}return s.join("&").replace(/%20/g,"+");
}});
jQuery.fn.extend({show:function(speed,callback){return speed?this.animate({height:"show",width:"show",opacity:"show"},speed,callback):this.filter(":hidden").each(function(){this.style.display=this.oldblock||"";
if(jQuery.css(this,"display")=="none"){var elem=jQuery("<"+this.tagName+" />").appendTo("body");
this.style.display=elem.css("display");
if(this.style.display=="none"){this.style.display="block";
}elem.remove();
}}).end();
},hide:function(speed,callback){return speed?this.animate({height:"hide",width:"hide",opacity:"hide"},speed,callback):this.filter(":visible").each(function(){this.oldblock=this.oldblock||jQuery.css(this,"display");
this.style.display="none";
}).end();
},_toggle:jQuery.fn.toggle,toggle:function(fn,fn2){return jQuery.isFunction(fn)&&jQuery.isFunction(fn2)?this._toggle.apply(this,arguments):fn?this.animate({height:"toggle",width:"toggle",opacity:"toggle"},fn,fn2):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();
});
},slideDown:function(speed,callback){return this.animate({height:"show"},speed,callback);
},slideUp:function(speed,callback){return this.animate({height:"hide"},speed,callback);
},slideToggle:function(speed,callback){return this.animate({height:"toggle"},speed,callback);
},fadeIn:function(speed,callback){return this.animate({opacity:"show"},speed,callback);
},fadeOut:function(speed,callback){return this.animate({opacity:"hide"},speed,callback);
},fadeTo:function(speed,to,callback){return this.animate({opacity:to},speed,callback);
},animate:function(prop,speed,easing,callback){var optall=jQuery.speed(speed,easing,callback);
return this[optall.queue===false?"each":"queue"](function(){if(this.nodeType!=1){return false;
}var opt=jQuery.extend({},optall),p,hidden=jQuery(this).is(":hidden"),self=this;
for(p in prop){if(prop[p]=="hide"&&hidden||prop[p]=="show"&&!hidden){return opt.complete.call(this);
}if(p=="height"||p=="width"){opt.display=jQuery.css(this,"display");
opt.overflow=this.style.overflow;
}}if(opt.overflow!=null){this.style.overflow="hidden";
}opt.curAnim=jQuery.extend({},prop);
jQuery.each(prop,function(name,val){var e=new jQuery.fx(self,opt,name);
if(/toggle|show|hide/.test(val)){e[val=="toggle"?hidden?"show":"hide":val](prop);
}else{var parts=val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),start=e.cur(true)||0;
if(parts){var end=parseFloat(parts[2]),unit=parts[3]||"px";
if(unit!="px"){self.style[name]=(end||1)+unit;
start=((end||1)/e.cur(true))*start;
self.style[name]=start+unit;
}if(parts[1]){end=((parts[1]=="-="?-1:1)*end)+start;
}e.custom(start,end,unit);
}else{e.custom(start,val,"");
}}});
return true;
});
},queue:function(type,fn){if(jQuery.isFunction(type)||(type&&type.constructor==Array)){fn=type;
type="fx";
}if(!type||(typeof type=="string"&&!fn)){return queue(this[0],type);
}return this.each(function(){if(fn.constructor==Array){queue(this,type,fn);
}else{queue(this,type).push(fn);
if(queue(this,type).length==1){fn.call(this);
}}});
},stop:function(clearQueue,gotoEnd){var timers=jQuery.timers;
if(clearQueue){this.queue([]);
}this.each(function(){for(var i=timers.length-1;
i>=0;
i--){if(timers[i].elem==this){if(gotoEnd){timers[i](true);
}timers.splice(i,1);
}}});
if(!gotoEnd){this.dequeue();
}return this;
}});
var queue=function(elem,type,array){if(elem){type=type||"fx";
var q=jQuery.data(elem,type+"queue");
if(!q||array){q=jQuery.data(elem,type+"queue",jQuery.makeArray(array));
}}return q;
};
jQuery.fn.dequeue=function(type){type=type||"fx";
return this.each(function(){var q=queue(this,type);
q.shift();
if(q.length){q[0].call(this);
}});
};
jQuery.extend({speed:function(speed,easing,fn){var opt=speed&&speed.constructor==Object?speed:{complete:fn||!fn&&easing||jQuery.isFunction(speed)&&speed,duration:speed,easing:fn&&easing||easing&&easing.constructor!=Function&&easing};
opt.duration=(opt.duration&&opt.duration.constructor==Number?opt.duration:jQuery.fx.speeds[opt.duration])||jQuery.fx.speeds.def;
opt.old=opt.complete;
opt.complete=function(){if(opt.queue!==false){jQuery(this).dequeue();
}if(jQuery.isFunction(opt.old)){opt.old.call(this);
}};
return opt;
},easing:{linear:function(p,n,firstNum,diff){return firstNum+diff*p;
},swing:function(p,n,firstNum,diff){return((-Math.cos(p*Math.PI)/2)+0.5)*diff+firstNum;
}},timers:[],timerId:null,fx:function(elem,options,prop){this.options=options;
this.elem=elem;
this.prop=prop;
if(!options.orig){options.orig={};
}}});
jQuery.fx.prototype={update:function(){if(this.options.step){this.options.step.call(this.elem,this.now,this);
}(jQuery.fx.step[this.prop]||jQuery.fx.step._default)(this);
if(this.prop=="height"||this.prop=="width"){this.elem.style.display="block";
}},cur:function(force){if(this.elem[this.prop]!=null&&this.elem.style[this.prop]==null){return this.elem[this.prop];
}var r=parseFloat(jQuery.css(this.elem,this.prop,force));
return r&&r>-10000?r:parseFloat(jQuery.curCSS(this.elem,this.prop))||0;
},custom:function(from,to,unit){this.startTime=now();
this.start=from;
this.end=to;
this.unit=unit||this.unit||"px";
this.now=this.start;
this.pos=this.state=0;
this.update();
var self=this;
function t(gotoEnd){return self.step(gotoEnd);
}t.elem=this.elem;
jQuery.timers.push(t);
if(jQuery.timerId==null){jQuery.timerId=setInterval(function(){var timers=jQuery.timers;
for(var i=0;
i<timers.length;
i++){if(!timers[i]()){timers.splice(i--,1);
}}if(!timers.length){clearInterval(jQuery.timerId);
jQuery.timerId=null;
}},13);
}},show:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);
this.options.show=true;
this.custom(0,this.cur());
if(this.prop=="width"||this.prop=="height"){this.elem.style[this.prop]="1px";
}jQuery(this.elem).show();
},hide:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);
this.options.hide=true;
this.custom(this.cur(),0);
},step:function(gotoEnd){var t=now();
if(gotoEnd||t>this.options.duration+this.startTime){this.now=this.end;
this.pos=this.state=1;
this.update();
this.options.curAnim[this.prop]=true;
var done=true;
for(var i in this.options.curAnim){if(this.options.curAnim[i]!==true){done=false;
}}if(done){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;
this.elem.style.display=this.options.display;
if(jQuery.css(this.elem,"display")=="none"){this.elem.style.display="block";
}}if(this.options.hide){this.elem.style.display="none";
}if(this.options.hide||this.options.show){for(var p in this.options.curAnim){jQuery.attr(this.elem.style,p,this.options.orig[p]);
}}}if(done){this.options.complete.call(this.elem);
}return false;
}else{var n=t-this.startTime;
this.state=n/this.options.duration;
this.pos=jQuery.easing[this.options.easing||(jQuery.easing.swing?"swing":"linear")](this.state,n,0,1,this.options.duration);
this.now=this.start+((this.end-this.start)*this.pos);
this.update();
}return true;
}};
jQuery.extend(jQuery.fx,{speeds:{slow:600,fast:200,def:400},step:{scrollLeft:function(fx){fx.elem.scrollLeft=fx.now;
},scrollTop:function(fx){fx.elem.scrollTop=fx.now;
},opacity:function(fx){jQuery.attr(fx.elem.style,"opacity",fx.now);
},_default:function(fx){fx.elem.style[fx.prop]=fx.now+fx.unit;
}}});
jQuery.fn.offset=function(){var left=0,top=0,elem=this[0],results;
if(elem){with(jQuery.browser){var parent=elem.parentNode,offsetChild=elem,offsetParent=elem.offsetParent,doc=elem.ownerDocument,safari2=safari&&parseInt(version)<522&&!/adobeair/i.test(userAgent),css=jQuery.curCSS,fixed=css(elem,"position")=="fixed";
if(elem.getBoundingClientRect){var box=elem.getBoundingClientRect();
add(box.left+Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),box.top+Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));
add(-doc.documentElement.clientLeft,-doc.documentElement.clientTop);
}else{add(elem.offsetLeft,elem.offsetTop);
while(offsetParent){add(offsetParent.offsetLeft,offsetParent.offsetTop);
if(mozilla&&!/^t(able|d|h)$/i.test(offsetParent.tagName)||safari&&!safari2){border(offsetParent);
}if(!fixed&&css(offsetParent,"position")=="fixed"){fixed=true;
}offsetChild=/^body$/i.test(offsetParent.tagName)?offsetChild:offsetParent;
offsetParent=offsetParent.offsetParent;
}while(parent&&parent.tagName&&!/^body|html$/i.test(parent.tagName)){if(!/^inline|table.*$/i.test(css(parent,"display"))){add(-parent.scrollLeft,-parent.scrollTop);
}if(mozilla&&css(parent,"overflow")!="visible"){border(parent);
}parent=parent.parentNode;
}if((safari2&&(fixed||css(offsetChild,"position")=="absolute"))||(mozilla&&css(offsetChild,"position")!="absolute")){add(-doc.body.offsetLeft,-doc.body.offsetTop);
}if(fixed){add(Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));
}}results={top:top,left:left};
}}function border(elem){add(jQuery.curCSS(elem,"borderLeftWidth",true),jQuery.curCSS(elem,"borderTopWidth",true));
}function add(l,t){left+=parseInt(l,10)||0;
top+=parseInt(t,10)||0;
}return results;
};
jQuery.fn.extend({position:function(){var left=0,top=0,results;
if(this[0]){var offsetParent=this.offsetParent(),offset=this.offset(),parentOffset=/^body|html$/i.test(offsetParent[0].tagName)?{top:0,left:0}:offsetParent.offset();
offset.top-=num(this,"marginTop");
offset.left-=num(this,"marginLeft");
parentOffset.top+=num(offsetParent,"borderTopWidth");
parentOffset.left+=num(offsetParent,"borderLeftWidth");
results={top:offset.top-parentOffset.top,left:offset.left-parentOffset.left};
}return results;
},offsetParent:function(){var offsetParent=this[0].offsetParent;
while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&jQuery.css(offsetParent,"position")=="static")){offsetParent=offsetParent.offsetParent;
}return jQuery(offsetParent);
}});
jQuery.each(["Left","Top"],function(i,name){var method="scroll"+name;
jQuery.fn[method]=function(val){if(!this[0]){return ;
}return val!=undefined?this.each(function(){this==window||this==document?window.scrollTo(!i?val:jQuery(window).scrollLeft(),i?val:jQuery(window).scrollTop()):this[method]=val;
}):this[0]==window||this[0]==document?self[i?"pageYOffset":"pageXOffset"]||jQuery.boxModel&&document.documentElement[method]||document.body[method]:this[0][method];
};
});
jQuery.each(["Height","Width"],function(i,name){var tl=i?"Left":"Top",br=i?"Right":"Bottom";
jQuery.fn["inner"+name]=function(){return this[name.toLowerCase()]()+num(this,"padding"+tl)+num(this,"padding"+br);
};
jQuery.fn["outer"+name]=function(margin){return this["inner"+name]()+num(this,"border"+tl+"Width")+num(this,"border"+br+"Width")+(margin?num(this,"margin"+tl)+num(this,"margin"+br):0);
};
});
})();


/* json2.js */
if(!this.JSON){JSON=function(){function f(n){return n<10?"0"+n:n;
}Date.prototype.toJSON=function(key){return this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z";
};
String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();
};
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapeable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;
function quote(string){escapeable.lastIndex=0;
return escapeable.test(string)?'"'+string.replace(escapeable,function(a){var c=meta[a];
if(typeof c==="string"){return c;
}return"\\u"+("0000"+(+(a.charCodeAt(0))).toString(16)).slice(-4);
})+'"':'"'+string+'"';
}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];
if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key);
}if(typeof rep==="function"){value=rep.call(holder,key,value);
}switch(typeof value){case"string":return quote(value);
case"number":return isFinite(value)?String(value):"null";
case"boolean":case"null":return String(value);
case"object":if(!value){return"null";
}gap+=indent;
partial=[];
if(typeof value.length==="number"&&!(value.propertyIsEnumerable("length"))){length=value.length;
for(i=0;
i<length;
i+=1){partial[i]=str(i,value)||"null";
}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";
gap=mind;
return v;
}if(rep&&typeof rep==="object"){length=rep.length;
for(i=0;
i<length;
i+=1){k=rep[i];
if(typeof k==="string"){v=str(k,value);
if(v){partial.push(quote(k)+(gap?": ":":")+v);
}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);
if(v){partial.push(quote(k)+(gap?": ":":")+v);
}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";
gap=mind;
return v;
}}return{stringify:function(value,replacer,space){var i;
gap="";
indent="";
if(typeof space==="number"){for(i=0;
i<space;
i+=1){indent+=" ";
}}else{if(typeof space==="string"){indent=space;
}}rep=replacer;
if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify");
}return str("",{"":value});
},parse:function(text,reviver){var j;
function walk(holder,key){var k,v,value=holder[key];
if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);
if(v!==undefined){value[k]=v;
}else{delete value[k];
}}}}return reviver.call(holder,key,value);
}cx.lastIndex=0;
if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+(+(a.charCodeAt(0))).toString(16)).slice(-4);
});
}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");
return typeof reviver==="function"?walk({"":j},""):j;
}throw new SyntaxError("JSON.parse");
}};
}();
}

/* rison.js */
if(typeof rison=="undefined"){window.rison={};
}rison.uri_ok={"~":true,"!":true,"*":true,"(":true,")":true,"-":true,"_":true,".":true,",":true,":":true,"@":true,"$":true,"'":true,"/":true};
(function(){var A=[];
for(var B=0;
B<16;
B++){for(var C=0;
C<16;
C++){if(B+C==0){continue;
}var D=String.fromCharCode(B*16+C);
if(!/\w|[-_.\/~]/.test(D)){A.push("\\u00"+B.toString(16)+C.toString(16));
}}}rison.not_idchar=A.join("");
})();
rison.not_idchar=" '!:(),*@$";
rison.not_idstart="-0123456789";
(function(){var A="[^"+rison.not_idstart+rison.not_idchar+"][^"+rison.not_idchar+"]*";
rison.id_ok=new RegExp("^"+A+"$");
rison.next_id=new RegExp(A,"g");
})();
rison.quote=function(A){var B=rison.uri_ok;
if(/^[A-Za-z0-9_-]*$/.test(A)){return A;
}A=A.replace(/([^A-Za-z0-9_-])/g,function(D,C){var E=B[C];
if(E){return C;
}return encodeURIComponent(C);
});
return A.replace(/%20/g,"+");
};
(function(){var B={"'":true,"!":true},A={array:function(D){var F=["!("],C,I,H,E=D.length,G;
for(H=0;
H<E;
H+=1){G=D[H];
I=A[typeof G];
if(I){G=I(G);
if(typeof G=="string"){if(C){F[F.length]=",";
}F[F.length]=G;
C=true;
}}}F[F.length]=")";
return F.join("");
},"boolean":function(C){if(C){return"!t";
}return"!f";
},"null":function(C){return"!n";
},number:function(C){if(!isFinite(C)){return"!n";
}return String(C).replace(/\+/,"");
},object:function(D){if(D){if(D instanceof Array){return A.array(D);
}if(typeof D.__prototype__==="object"&&typeof D.__prototype__.encode_rison!=="undefined"){return D.encode_rison();
}var E=["("],C,H,G,F,I,J=[];
for(G in D){J[J.length]=G;
}J.sort();
for(I=0;
I<J.length;
I++){G=J[I];
F=D[G];
H=A[typeof F];
if(H){F=H(F);
if(typeof F=="string"){if(C){E[E.length]=",";
}E.push(A.string(G),":",F);
C=true;
}}}E[E.length]=")";
return E.join("");
}return"!n";
},string:function(C){if(C==""){return"''";
}if(rison.id_ok.test(C)){return C;
}C=C.replace(/(['!])/g,function(E,D){if(B[D]){return"!"+D;
}return D;
});
return"'"+C+"'";
},undefined:function(C){throw new Error("rison can't encode the undefined value");
}};
rison.encode=function(C){return A[typeof C](C);
};
rison.encode_object=function(C){if(typeof C!="object"||C===null||C instanceof Array){throw new Error("rison.encode_object expects an object argument");
}var D=A[typeof C](C);
return D.substring(1,D.length-1);
};
rison.encode_array=function(C){if(!(C instanceof Array)){throw new Error("rison.encode_array expects an array argument");
}var D=A[typeof C](C);
return D.substring(2,D.length-1);
};
rison.encode_uri=function(C){return rison.quote(A[typeof C](C));
};
})();
rison.decode=function(B){var A=function(D){throw Error("rison decoder error: "+D);
};
var C=new rison.parser(A);
return C.parse(B);
};
rison.decode_object=function(A){return rison.decode("("+A+")");
};
rison.decode_array=function(A){return rison.decode("!("+A+")");
};
rison.parser=function(A){this.errorHandler=A;
};
rison.parser.WHITESPACE="";
rison.parser.prototype.setOptions=function(A){if(A["errorHandler"]){this.errorHandler=A.errorHandler;
}};
rison.parser.prototype.parse=function(B){this.string=B;
this.index=0;
this.message=null;
var A=this.readValue();
if(!this.message&&this.next()){A=this.error("unable to parse string as rison: '"+rison.encode(B)+"'");
}if(this.message&&this.errorHandler){this.errorHandler(this.message,this.index);
}return A;
};
rison.parser.prototype.error=function(A){if(typeof (console)!="undefined"){console.log("rison parser error: ",A);
}this.message=A;
return undefined;
};
rison.parser.prototype.readValue=function(){var F=this.next();
var D=F&&this.table[F];
if(D){return D.apply(this);
}var C=this.string;
var B=this.index-1;
rison.next_id.lastIndex=B;
var A=rison.next_id.exec(C);
if(A.length>0){var E=A[0];
this.index=B+E.length;
return E;
}if(F){return this.error("invalid character: '"+F+"'");
}return this.error("empty expression");
};
rison.parser.parse_array=function(D){var A=[];
var C;
while((C=D.next())!=")"){if(!C){return D.error("unmatched '!('");
}if(A.length){if(C!=","){D.error("missing ','");
}}else{if(C==","){return D.error("extra ','");
}else{--D.index;
}}var B=D.readValue();
if(typeof B=="undefined"){return undefined;
}A.push(B);
}return A;
};
rison.parser.bangs={t:true,f:false,n:null,"(":rison.parser.parse_array};
rison.parser.prototype.table={"!":function(){var B=this.string;
var C=B.charAt(this.index++);
if(!C){return this.error('"!" at end of input');
}var A=rison.parser.bangs[C];
if(typeof (A)=="function"){return A.call(null,this);
}else{if(typeof (A)=="undefined"){return this.error('unknown literal: "!'+C+'"');
}}return A;
},"(":function(){var D={};
var E;
var C=0;
while((E=this.next())!=")"){if(C){if(E!=","){this.error("missing ','");
}}else{if(E==","){return this.error("extra ','");
}else{--this.index;
}}var B=this.readValue();
if(typeof B=="undefined"){return undefined;
}if(this.next()!=":"){return this.error("missing ':'");
}var A=this.readValue();
if(typeof A=="undefined"){return undefined;
}D[B]=A;
C++;
}return D;
},"'":function(){var C=this.string;
var B=this.index;
var E=B;
var A=[];
var D;
while((D=C.charAt(B++))!="'"){if(!D){return this.error('unmatched "\'"');
}if(D=="!"){if(E<B-1){A.push(C.slice(E,B-1));
}D=C.charAt(B++);
if("!'".indexOf(D)>=0){A.push(D);
}else{return this.error('invalid string escape: "!'+D+'"');
}E=B;
}}if(E<B-1){A.push(C.slice(E,B-1));
}this.index=B;
return A.length==1?A[0]:A.join("");
},"-":function(){var B=this.string;
var A=this.index;
var G=A-1;
var C="int";
var F="-";
var D={"int+.":"frac","int+e":"exp","frac+e":"exp"};
do{var E=B.charAt(A++);
if(!E){break;
}if("0"<=E&&E<="9"){continue;
}if(F.indexOf(E)>=0){F="";
continue;
}C=D[C+"+"+E.toLowerCase()];
if(C=="exp"){F="-";
}}while(C);
this.index=--A;
B=B.slice(G,A);
if(B=="-"){return this.error("invalid number");
}return Number(B);
}};
(function(B){for(var A=0;
A<=9;
A++){B[String(A)]=B["-"];
}})(rison.parser.prototype.table);
rison.parser.prototype.next=function(){var B=this.string;
var A=this.index;
do{if(A==B.length){return undefined;
}var C=B.charAt(A++);
}while(rison.parser.WHITESPACE.indexOf(C)>=0);
this.index=A;
return C;
};


/* jquery.cookie.js */
jQuery.cookie=function(B,I,L){if(typeof I!="undefined"){L=L||{};
if(I===null){I="";
L.expires=-1;
}var E="";
if(L.expires&&(typeof L.expires=="number"||L.expires.toUTCString)){var F;
if(typeof L.expires=="number"){F=new Date();
F.setTime(F.getTime()+(L.expires*24*60*60*1000));
}else{F=L.expires;
}E="; expires="+F.toUTCString();
}var K=L.path?"; path="+(L.path):"";
var G=L.domain?"; domain="+(L.domain):"";
var A=L.secure?"; secure":"";
document.cookie=[B,"=",encodeURIComponent(I),E,K,G,A].join("");
}else{var D=null;
if(document.cookie&&document.cookie!=""){var J=document.cookie.split(";");
for(var H=0;
H<J.length;
H++){var C=jQuery.trim(J[H]);
if(C.substring(0,B.length+1)==(B+"=")){D=decodeURIComponent(C.substring(B.length+1));
break;
}}}return D;
}};


/* jsonp-queue.js */
(function(){var A=window.MetawebSuite;
A.core.JsonpQueue=function(){this._pendingCallIDs={};
this._callInProgress=0;
};
A.core.JsonpQueue.prototype.cancelAll=function(){this._pendingCallIDs={};
};
A.core.JsonpQueue.prototype.call=function(B,E,G,C){if(this._callInProgress==0){document.body.style.cursor="progress";
}this._callInProgress++;
var F=new Date().getTime()+"x"+Math.floor(Math.random()*1000);
var I=document.createElement("script");
I.setAttribute("onerror","err"+F+"();");
B+=(B.indexOf("?")<0?"?":"&")+"callback=cb"+F;
I.setAttribute("src",B);
var K=this;
var D=function(){K._callInProgress--;
if(K._callInProgress==0){document.body.style.cursor="auto";
}if(!(C)){I.parentNode.removeChild(I);
}try{delete window["cb"+F];
delete window["err"+F];
}catch(L){window["cb"+F]=undefined;
window["err"+F]=undefined;
}if(F in K._pendingCallIDs){delete K._pendingCallIDs[F];
return true;
}else{return false;
}};
var J=function(M){if(D()){try{E(M);
}catch(L){A.system.exception(L);
}}};
var H=function(){if(D()){if(typeof G=="function"){try{G(B);
}catch(L){A.system.exception(L);
}}}};
window["cb"+F]=J;
window["err"+F]=H;
this._pendingCallIDs[F]=true;
document.getElementsByTagName("head")[0].appendChild(I);
};
})();


/* listener-queue.js */
(function(){var A=window.MetawebSuite;
A.core.ListenerQueue=function(B){this._listeners=[];
this._wildcardHandlerName=B;
};
A.core.ListenerQueue.prototype={add:function(B){this._listeners.push(B);
},remove:function(D){var C=this._listeners;
for(var B=0;
B<C.length;
B++){if(C[B]==D){C.splice(B,1);
break;
}}},fire:function(C,B){var E=[].concat(this._listeners);
for(var D=0;
D<E.length;
D++){var F=E[D];
if(C in F){try{F[C].apply(F,B);
}catch(G){A.system.exception(G,"Error firing event of name "+C);
}}else{if(this._wildcardHandlerName!=null&&this._wildcardHandlerName in F){try{F[this._wildcardHandlerName].apply(F,[C]);
}catch(G){A.system.exception(G,"Error firing event of name "+C+" to wildcard handler");
}}}}}};
})();


/* misc.js */
window.myJQuery=window.jQuery;
(function(){var A=function(E){if(E instanceof Array){var B=[];
for(var C=0;
C<E.length;
C++){B.push(A(E[C]));
}return B;
}else{if(typeof E=="object"){var D={};
for(var F in E){if(E.hasOwnProperty(F)){D[F]=A(E[F]);
}}return D;
}else{return E;
}}};
mw.system.clone=A;
})();


/* string.js */
(function(){String.startsWith=function(B,A){return B!=null&&B.length>=A.length&&B.substr(0,A.length)==A;
};
String.endsWith=function(B,A){return B!=null&&B.length>=A.length&&B.substr(B.length-A.length)==A;
};
String.trim=function(A){return A.replace(/^\s+/,"").replace(/\s+$/,"");
};
String.padNumber=function(A){if(A<10){return"00"+A;
}else{if(A<100){return"0"+A;
}else{return A;
}}};
String.formatNumberWithSeparators=function(B){if(B<1){return B;
}else{var A=[];
while(B>1000){A.unshift(padNumber(B%1000));
B=Math.floor(B/1000);
}A.unshift(B);
return A.join(",");
}};
String.formatNumberWithSuffix=function(A){if(A>1000000000){return(Math.floor(A/100000000)/10)+"B";
}else{if(A>1000000){return(Math.floor(A/100000)/10)+"M";
}else{if(A>1000){return(Math.floor(A/100)/10)+"K";
}else{if(A>1){return A;
}else{if(A>0.001){return(Math.floor(A/0.0001)/10)+"m";
}else{if(A>0.000001){return(Math.floor(A/1e-7)/10)+"u";
}else{return A;
}}}}}}};
})();


/* terminal.js */
window.MetawebSuite.system.onFinishLoadingPackage("metaweb-suite-core");


/* ui-package.js */
(function() {
    mw.system.onStartLoadingNativePackage(
        "ui",
        [   "ui.js",
            "history.js",
            "layers.js",
            "dnd.js",
            "animation.js",
            "menus.js",
            "color-coder.js",
            "ui-context.js",
            "terminal.js"
        ],
        [   "ui.css"
        ]
    );
})();


/* ui-bundle.js */


/* animation.js */
(function(){var A=window.MetawebSuite;
A.ui.Animation=function(C,F,E,D,B){this.f=C;
this.cont=(typeof B=="function")?B:function(){};
this.from=F;
this.to=E;
this.current=F;
this.duration=D;
this.start=new Date().getTime();
this.timePassed=0;
};
A.ui.Animation.prototype.run=function(){var B=this;
window.setTimeout(function(){B.step();
},50);
};
A.ui.Animation.prototype.step=function(){this.timePassed+=50;
var C=this.timePassed/this.duration;
var B=-Math.cos(C*Math.PI)/2+0.5;
var E=B*(this.to-this.from)+this.from;
try{this.f(E,E-this.current);
}catch(D){}this.current=E;
if(this.timePassed<this.duration){this.run();
}else{this.f(this.to,0);
this["cont"]();
}};
})();


/* color-coder.js */
function DefaultColorCoder(){this._colorMap={};
this._colorMax=0;
}DefaultColorCoder.defaultColors=["#FF9000","#5D7CBA","#A97838","#8B9BBA","#FFC77F","#003EBA","#29447B","#543C1C"];
DefaultColorCoder.prototype.getColorForKey=function(B){if(B in this._colorMap){return this._colorMap[B];
}else{var A=this._colorMap[B]=DefaultColorCoder.defaultColors[this._colorMax];
this._colorMax=(this._colorMax+1)%DefaultColorCoder.defaultColors.length;
return A;
}};
DefaultColorCoder.prototype.getDefaultColor=function(){return"#FF9000";
};


/* dnd.js */
(function(){var B=window.MetawebSuite;
var A=B.ui.dnd={_initialized:false,_draggedElement:null,_draggedElementCallback:null,_dropTargetHighlightElement:null,_lastCoords:null,_ghostCoords:null,_draggingMode:"",_dragging:false};
A.initialize=function(){if(A._initialized){return ;
}myJQuery(document.body).bind("mousedown",A._onBodyMouseDown).bind("mousemove",A._onBodyMouseMove).bind("mouseup",A._onBodyMouseUp).bind("keydown",A._onBodyKeyDown).bind("keyup",A._onBodyKeyUp);
A._initialized=true;
};
A.makeDraggable=function(D,F,C){A.initialize();
var E=function(G){return A._handleMouseDown(this,G,F);
};
myJQuery(D).mousedown(E);
return{dispose:function(){myJQuery(D).unbind("mousedown",E);
}};
};
A._handleMouseDown=function(D,C,E){A._draggedElement=D;
A._draggedElementCallback=E;
A._lastCoords={x:C.clientX,y:C.clientY};
return B.ui.cancelEvent(C);
};
A._onBodyMouseDown=function(C){if(!("eventPhase" in C)||C.eventPhase==C.BUBBLING_PHASE){B.ui.layers.cancelPopups(C);
}};
A._onBodyKeyDown=function(C){if(A._dragging){if(C.keyCode==27){A._cancelDragging();
}else{if((C.keyCode==17||C.keyCode==16)&&A._draggingMode!="copy"){A._draggingMode="copy";
var D=B.ui.createTranslucentImage(B.ui.params.urlPrefix+"images/copy.png");
D.style.position="absolute";
D.style.left=(A._ghostCoords.left-16)+"px";
D.style.top=(A._ghostCoords.top)+"px";
document.body.appendChild(D);
A._draggingModeIndicatorElmt=D;
}}}};
A._onBodyKeyUp=function(C){if(A._dragging){if(C.keyCode==17||C.keyCode==16){A._draggingMode="";
if(A._draggingModeIndicatorElmt!=null){document.body.removeChild(A._draggingModeIndicatorElmt);
A._draggingModeIndicatorElmt=null;
}}}};
A._onBodyMouseMove=function(O){if(A._draggedElement!=null){var P=A._draggedElementCallback;
var F=A._lastCoords;
var N=O.clientX-F.x;
var K=O.clientY-F.y;
if(!A._dragging){if(Math.abs(N)>5||Math.abs(K)>5){try{if("onDragStart" in P){P.onDragStart();
}if("ghost" in P&&P.ghost){var L=A._draggedElement;
A._ghostCoords=SimileAjax.DOM.getPageCoordinates(L);
A._ghostCoords.left+=N;
A._ghostCoords.top+=K;
var Q=L.cloneNode(true);
Q.style.position="absolute";
Q.style.left=A._ghostCoords.left+"px";
Q.style.top=A._ghostCoords.top+"px";
Q.style.zIndex=1000;
SimileAjax.Graphics.setOpacity(Q,50);
document.body.appendChild(Q);
P._ghostElmt=Q;
}A._dragging=true;
A._lastCoords={x:O.clientX,y:O.clientY};
document.body.focus();
}catch(I){B.system.exception(I,"mw.ui.dnd: Error handling mouse down");
A._cancelDragging();
}}}else{try{A._lastCoords={x:O.clientX,y:O.clientY};
if("onDragBy" in P){P.onDragBy(N,K);
}if("_ghostElmt" in P){var Q=P._ghostElmt;
A._ghostCoords.left+=N;
A._ghostCoords.top+=K;
Q.style.left=A._ghostCoords.left+"px";
Q.style.top=A._ghostCoords.top+"px";
if(A._draggingModeIndicatorElmt!=null){var J=A._draggingModeIndicatorElmt;
J.style.left=(A._ghostCoords.left-16)+"px";
J.style.top=A._ghostCoords.top+"px";
}if("droppable" in P&&P.droppable){var M=B.ui.getEventPageCoordinates(O);
var H=B.ui.hittest(M.x,M.y,[A._ghostElmt,A._dropTargetHighlightElement]);
H=A._findDropTarget(H);
if(H!=A._potentialDropTarget){if(A._dropTargetHighlightElement!=null){document.body.removeChild(A._dropTargetHighlightElement);
A._dropTargetHighlightElement=null;
A._potentialDropTarget=null;
}var G=false;
if(H!=null){if((!("canDropOn" in P)||P.canDropOn(H))&&(!("canDrop" in H)||H.canDrop(A._draggedElement))){G=true;
}}if(G){var D=4;
var E=B.ui.getPageCoordinates(H);
var C=B.ui.createHTMLElement("div");
C.style.border=D+"px solid yellow";
C.style.backgroundColor="yellow";
C.style.position="absolute";
C.style.left=E.left+"px";
C.style.top=E.top+"px";
C.style.width=(H.offsetWidth-D*2)+"px";
C.style.height=(H.offsetHeight-D*2)+"px";
B.ui.setOpacity(C,30);
document.body.appendChild(C);
A._potentialDropTarget=H;
A._dropTargetHighlightElement=C;
}}}}}catch(I){B.system.exception("WindowManager: Error handling mouse move",I);
A._cancelDragging();
}}return B.ui.cancelEvent(O);
}};
A._onBodyMouseUp=function(C){if(A._draggedElement!=null){try{if(A._dragging){var F=A._draggedElementCallback;
if("onDragEnd" in F){F.onDragEnd();
}if("droppable" in F&&F.droppable){var E=false;
var D=A._potentialDropTarget;
if(D!=null){if((!("canDropOn" in F)||F.canDropOn(D))&&(!("canDrop" in D)||D.canDrop(A._draggedElement))){if("onDropOn" in F){F.onDropOn(D);
}D.ondrop(A._draggedElement,A._draggingMode);
E=true;
}}if(!E){}}}}finally{A._cancelDragging();
}return B.ui.cancelEvent(C);
}};
A._cancelDragging=function(){var D=A._draggedElementCallback;
if("_ghostElmt" in D){var C=D._ghostElmt;
document.body.removeChild(C);
delete D._ghostElmt;
}if(A._dropTargetHighlightElement!=null){document.body.removeChild(A._dropTargetHighlightElement);
A._dropTargetHighlightElement=null;
}if(A._draggingModeIndicatorElmt!=null){document.body.removeChild(A._draggingModeIndicatorElmt);
A._draggingModeIndicatorElmt=null;
}A._draggedElement=null;
A._draggedElementCallback=null;
A._potentialDropTarget=null;
A._dropTargetHighlightElement=null;
A._lastCoords=null;
A._ghostCoords=null;
A._draggingMode="";
A._dragging=false;
};
A._findDropTarget=function(C){while(C!=null){if("ondrop" in C&&(typeof C.ondrop)=="function"){break;
}C=C.parentNode;
}return C;
};
})();


/* history.js */
(function(){var B=window.MetawebSuite;
var A=B.ui.history={maxHistoryLength:10,historyFile:"__history__.html",enabled:true,_initialized:false,_actions:[],_baseIndex:0,_currentIndex:0};
A.formatHistoryEntryTitle=function(C){return A._plainDocumentTitle+" {"+C+"}";
};
A.initialize=function(){if(A._initialized){return ;
}A._listeners=new B.core.ListenerQueue();
if(A.enabled){A._plainDocumentTitle=document.title;
var C=B.ui.createHTMLElement("iframe");
C.id="simile-ajax-history";
C.style.position="absolute";
C.style.width="10px";
C.style.height="10px";
C.style.top="0px";
C.style.left="0px";
C.style.visibility="hidden";
C.src=A.historyFile+"?0";
document.body.appendChild(C);
myJQuery(C).bind("load",A._handleIFrameOnLoad);
A._iframe=C;
}A._initialized=true;
};
A.addListener=function(C){A.initialize();
A._listeners.add(C);
};
A.removeListener=function(C){A.initialize();
A._listeners.remove(C);
};
A.addAction=function(C){A.initialize();
A._listeners.fire("onBeforePerform",[C]);
window.setTimeout(function(){try{C.perform();
A._listeners.fire("onAfterPerform",[C]);
if(A.enabled){A._actions=A._actions.slice(0,A._currentIndex-A._baseIndex);
A._actions.push(C);
A._currentIndex++;
var E=A._actions.length-A.maxHistoryLength;
if(E>0){A._actions=A._actions.slice(E);
A._baseIndex+=E;
}try{A._iframe.contentWindow.location.href=A.historyFile+"?"+A._currentIndex;
}catch(D){var F=A.formatHistoryEntryTitle(C.label);
document.title=F;
}}}catch(D){B.system.exception(D,"Error adding action {"+C.label+"} to history");
}},0);
};
A.addLengthyAction=function(E,C,D){A.addAction({perform:E,undo:C,label:D,uiLayer:B.ui.layers.getBaseLayer(),lengthy:true});
};
A._handleIFrameOnLoad=function(){try{var C=A._iframe.contentWindow.location.href;
var E=C.indexOf("?");
var I=(E<0)?0:Math.max(0,parseInt(C.substr(E+1)));
var H=function(){var J=I-A._currentIndex;
A._currentIndex+=J;
A._baseIndex+=J;
A._iframe.contentWindow.location.search="?"+I;
};
if(I<A._currentIndex){A._listeners.fire("onBeforeUndoSeveral",[]);
window.setTimeout(function(){while(A._currentIndex>I&&A._currentIndex>A._baseIndex){A._currentIndex--;
var J=A._actions[A._currentIndex-A._baseIndex];
try{J.undo();
}catch(K){B.core.exception(K,"History: Failed to undo action {"+J.label+"}");
}}A._listeners.fire("onAfterUndoSeveral",[]);
H();
},0);
}else{if(I>A._currentIndex){A._listeners.fire("onBeforeRedoSeveral",[]);
window.setTimeout(function(){while(A._currentIndex<I&&A._currentIndex-A._baseIndex<A._actions.length){var J=A._actions[A._currentIndex-A._baseIndex];
try{J.perform();
}catch(K){B.core.exception(K,"History: Failed to redo action {"+J.label+"}");
}A._currentIndex++;
}A._listeners.fire("onAfterRedoSeveral",[]);
H();
},0);
}else{var D=A._currentIndex-A._baseIndex-1;
var G=(D>=0&&D<A._actions.length)?A.formatHistoryEntryTitle(A._actions[D].label):A._plainDocumentTitle;
A._iframe.contentWindow.document.title=G;
document.title=G;
}}}catch(F){}};
A.getNextUndoAction=function(){try{var C=A._currentIndex-A._baseIndex-1;
return A._actions[C];
}catch(D){return null;
}};
A.getNextRedoAction=function(){try{var C=A._currentIndex-A._baseIndex;
return A._actions[C];
}catch(D){return null;
}};
})();


/* layers.js */
(function(){var B=window.MetawebSuite;
var A=B.ui.layers={_initialized:false,_layers:[]};
A.initialize=function(){if(A._initialized){return ;
}A._layers.push({index:0});
myJQuery(window).mousedown(function(C){A.cancelPopups(C);
});
myJQuery(window).keyup(function(C){if(C.keyCode==27){A.cancelTopMostPopup();
}});
A._initialized=true;
};
A.getBaseLayer=function(){A.initialize();
return A._layers[0];
};
A.getHighestLayer=function(){A.initialize();
return A._layers[A._layers.length-1];
};
A.tryAccessLayer=function(C){A.initialize();
if(A._canProcessEventAtLayer(C)){A._popToLayer(C.index);
return true;
}return false;
};
A.pushLayer=function(C,D){A.initialize();
return A._pushLayer(C,D,false);
};
A.pushEphemeralLayer=function(C,D){A.initialize();
return A._pushLayer(C,D,true);
};
A._pushLayer=function(D,E,F){var C={index:A._layers.length,onPop:D,ephemeral:F,elmts:E||[]};
A._layers.push(C);
return C;
};
A.popLayer=function(C){A.initialize();
A._popToLayer(C.index-1);
};
A.popAllLayers=function(){A.initialize();
A._popToLayer(0);
};
A._popToLayer=function(E){while(E+1<A._layers.length){try{var C=A._layers.pop();
if(C.onPop!=null){C.onPop();
}}catch(D){B.system.exception(D);
}}};
A._canProcessEventAtLayer=function(D){if(D.index==(A._layers.length-1)){return true;
}for(var C=D.index+1;
C<A._layers.length;
C++){if(!A._layers[C].ephemeral){return false;
}}return true;
};
A.cancelPopups=function(K){A.initialize();
var E=(K)?B.ui.getEventPageCoordinates(K):{x:-1,y:-1};
var H=A._layers.length-1;
while(H>0&&A._layers[H].ephemeral){var I=A._layers[H];
if(I.elmts!=null){var F=I.elmts;
var C=false;
for(var G=0;
G<F.length;
G++){var D=F[G];
var J=B.ui.getPageCoordinates(D);
if(E.x>=J.left&&E.x<(J.left+D.offsetWidth)&&E.y>=J.top&&E.y<(J.top+D.offsetHeight)){C=true;
break;
}}if(C){break;
}}H--;
}A._popToLayer(H);
};
A.cancelTopMostPopup=function(){if(A._layers.length>1){if(A._layers[A._layers.length-1].ephemeral){A._popToLayer(A._layers.length-2);
}}};
})();


/* menus.js */
(function(){var C=window.MetawebSuite;
var B=C.ui.menus={};
var A=B.PopupMenu=function(E){var G=C.ui.createHTMLElement("div");
G.className="menu-popup";
var F=C.ui.createHTMLElement("div");
F.className="menu-popup-body";
G.appendChild(F);
var D=this;
this.elmt=G;
this.bodyDiv=F;
this.close=function(){C.ui.removeFromDom(G);
};
this.open=function(){C.ui.addToDom(G);
var I=document.body.offsetWidth;
var H=document.body.offsetHeight;
var J=C.ui.getPageCoordinates(E);
G.style.top=(J.top+E.scrollHeight)+"px";
G.style.right=(I-(J.left+E.scrollWidth))+"px";
D.layer=C.ui.layers.pushEphemeralLayer(function(){D.close();
},[G]);
};
this.appendMenuItem=function(I,J,K){var H=C.ui.createHTMLElement("a");
H.className="menu-item";
H.href="javascript:";
myJQuery(H).click(function(M){if(C.ui.layers.tryAccessLayer(D.layer)){K(this,M);
}C.ui.layers.popLayer(D.layer);
return C.ui.cancelEvent(M);
});
var L=C.ui.createHTMLElement("div");
H.appendChild(L);
L.appendChild(C.ui.createTranslucentImage(J!=null?J:(C.ui.params.baseUrl+"images/blank-16x16.png")));
if(typeof I=="string"){L.appendChild(document.createTextNode(I));
}else{L.appendChild(I);
}F.appendChild(H);
return H;
};
this.appendSection=function(H){var I=C.ui.createHTMLElement("div");
I.className="menu-section";
I.appendChild(document.createTextNode(H));
F.appendChild(I);
return I;
};
this.appendSeparator=function(){var H=C.ui.createHTMLElement("hr");
F.appendChild(H);
};
};
})();


/* ui-context.js */
(function(){var B=window.MetawebSuite;
var A=B.ui.UIContext=function(C){this._parent=C?C:null;
this._settings={};
};
A.prototype.dispose=function(){};
A.prototype.getParentUIContext=function(){return this._parent;
};
A.prototype.getSetting=function(C){return C in this._settings?this._settings[C]:(this._parent!=null?this._parent.getSetting(C):undefined);
};
A.prototype.getBooleanSetting=function(E,C){var D=this.getSetting(E);
return D==undefined||D==null?C:D;
};
A.prototype.putSetting=function(C,D){this._settings[C]=D;
};
})();


/* ui.js */
(function(){var D=window.MetawebSuite;
D.ui.addToDom=function(E){document.body.appendChild(E);
};
D.ui.removeFromDom=function(E){E.parentNode.removeChild(E);
};
D.ui.createHTMLElement=document.contentType=="application/vnd.mozilla.xul+xml"?function(E){return document.createElementNS("http://www.w3.org/1999/xhtml",E);
}:function(E){return document.createElement(E);
};
D.ui.cancelEvent=function(E){E.returnValue=false;
E.cancelBubble=true;
if("preventDefault" in E){E.preventDefault();
}return false;
};
D.ui.getPageCoordinates=function(F){var I=0;
var H=0;
if(F.nodeType!=1){F=F.parentNode;
}var G=F;
while(G!=null){I+=G.offsetLeft;
H+=G.offsetTop;
G=G.offsetParent;
}var E=document.body;
while(F!=null&&F!=E){if("scrollLeft" in F){I-=F.scrollLeft;
H-=F.scrollTop;
}F=F.parentNode;
}return{left:I,top:H};
};
D.ui.getEventRelativeCoordinates=function(E,F){if(myJQuery.browser.msie){return{x:E.offsetX,y:E.offsetY};
}else{var G=D.ui.getPageCoordinates(F);
return{x:E.pageX-G.left,y:E.pageY-G.top};
}};
D.ui.getEventPageCoordinates=function(E){if(myJQuery.browser.msie){return{x:E.clientX+document.body.scrollLeft,y:E.clientY+document.body.scrollTop};
}else{return{x:E.pageX,y:E.pageY};
}};
D.ui.pngIsTranslucent=(!myJQuery.browser.msie)||(parseFloat(myJQuery.browser.version.substr(0,2))>6);
var B=function(E,G){var F=D.ui.createHTMLElement("img");
F.setAttribute("src",E);
if(G!=null){F.style.verticalAlign=G;
}return F;
};
var A=function(E,G){var F=D.ui.createHTMLElement("img");
F.style.width="1px";
F.style.height="1px";
F.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+E+"', sizingMethod='image')";
F.style.verticalAlign=(G!=null)?G:"middle";
return F;
};
D.ui.createTranslucentImage=D.ui.pngIsTranslucent?B:A;
D.ui.setOpacity=function(F,E){if(D.ui.pngIsTranslucent){var G=(E/100).toString();
F.style.opacity=G;
F.style.MozOpacity=G;
}else{F.style.filter="progid:DXImageTransform.Microsoft.Alpha(Style=0,Opacity="+E+")";
}};
var C=function(G,P,O,L){var Q=G.childNodes;
outer:for(var K=0;
K<Q.length;
K++){var E=Q[K];
for(var J=0;
J<L.length;
J++){if(E==L[J]){continue outer;
}}if(E.offsetWidth==0&&E.offsetHeight==0){var F=C(E,P,O,L);
if(F!=E){return F;
}}else{var N=0;
var I=0;
var H=E;
while(H){N+=H.offsetTop;
I+=H.offsetLeft;
H=H.offsetParent;
}if(I<=P&&N<=O&&(P-I)<E.offsetWidth&&(O-N)<E.offsetHeight){return C(E,P,O,L);
}else{if(E.nodeType==1&&E.tagName=="TR"){var M=C(E,P,O,L);
if(M!=E){return M;
}}}}}return G;
};
D.ui.hittest=function(E,G,F){return C(document.body,E,G,F);
};
D.ui.showLightboxForImage=function(J,G){var L=D.ui.createHTMLElement("div");
L.style.position="fixed";
L.style.top="0px";
L.style.left="0px";
L.style.width="100%";
L.style.height="100%";
L.style.background="black";
L.style.opacity=0.5;
L.style.zIndex=1000;
D.ui.addToDom(L);
var F=D.ui.createHTMLElement("div");
F.style.position="fixed";
F.style.top="0px";
F.style.left="0px";
F.style.width="100%";
F.style.height="100%";
F.style.zIndex=1001;
F.style.textAlign="center";
D.ui.addToDom(F);
var E=F.offsetHeight;
var I=Math.max(1,Math.floor(E/100)-1)*100;
var H=(typeof J=="string")?J:J.src;
var K=H.indexOf("?");
H=H.substr(0,K)+"?mode=fill&maxheight="+I;
F.innerHTML='<img src="'+H+'" style="margin-top: 50px; padding: 10px; border: 1px solid #aaa;" />';
F.onclick=function(){D.ui.removeFromDom(F);
D.ui.removeFromDom(L);
};
if(G){return D.ui.cancelEvent(G);
}};
})();


/* terminal.js */
window.MetawebSuite.system.onFinishLoadingPackage("metaweb-suite-ui");


/* freebase-package.js */
(function() {
    mw.system.onStartLoadingNativePackage(
        "freebase",
        [   "init.js",
            "mql.js",
            "schemas.js",
            "path.js",
            "dimension.js",
            "type-stack.js",
            "mpl/parser.js",
            "mpl/controls.js",
            "mpl/functions.js",
            "mpl/evaluator.js",
            "terminal.js"
        ],
        [
        ]
    );
})();


/* freebase-bundle.js */


/* init.js */
(function(){if("freebase-location" in mw.freebase.params){mw.freebase.location=mw.freebase.params["freebase-location"];
}else{if("freebase-location" in mw.system.urlParams){mw.freebase.location=mw.system.urlParams["freebase-location"];
}}if("location" in mw.freebase){var A=mw.freebase.location;
if(A=="sandbox"){mw.freebase.location="http://sandbox.freebase.com/";
}else{if(A.indexOf("://")<0){A="http://"+A;
}if(!String.endsWith(A,"/")){A=A+"/";
}mw.freebase.location=A;
}}else{mw.freebase.location="http://www.freebase.com/";
}mw.freebase.apiLocation=mw.freebase.location+"api/";
mw.freebase.serviceLocation=mw.freebase.apiLocation+"service/";
if(mw.freebase.location.indexOf("http://sandbox.")==0){mw.freebase.appsDomain="sandbox-freebaseapps.com";
}else{mw.freebase.appsDomain="freebaseapps.com";
}})();


/* dimension.js */
(function(){var C=window.MetawebSuite;
var B=C.freebase.Dimension=function(D){B._checkPath(D);
this._propertyPath=D.clone();
};
B.parseString=function(D){return new B(PropertyPath.parseString(D));
};
B._checkPath=function(D){var E=D.getSegmentCount();
if(E>2){throw new Error("Dimension's property path must have no more than two segments: "+D.toString());
}};
B.prototype.getSegmentCount=function(){return this._propertyPath.getSegmentCount();
};
B.prototype.getLastSegment=function(){return this._propertyPath.getLastSegment();
};
B.prototype.getLastPropertyID=function(){return this._propertyPath.getLastPropertyID();
};
B.prototype.toString=function(){return this._propertyPath.toString();
};
B.prototype.getPath=function(){return this._propertyPath.clone();
};
var A=C.freebase.DimensionPath=function(){this._dimensions=[];
};
A.prototype.getTotalPropertyPath=function(){};
})();


/* mql.js */
(function(){var B=window.MetawebSuite;
var A=B.freebase.mql={getJsonpQueue:function(){if(!("jsonpQueue" in A)){A.jsonpQueue=new B.core.JsonpQueue();
}return A.jsonpQueue;
},getMqlReadUrl:function(){if(!("mqlreadUrl" in A)){A.mqlreadUrl=B.freebase.serviceLocation+"mqlread";
}return A.mqlreadUrl;
},cancelAllQueries:function(){A.getJsonpQueue().cancelAll();
},error:function(C,D){B.system.log(C);
}};
A.readThroughQueue=function(I,J,F,G,E){var C=JSON.stringify({"q1":{"query":J}});
var D=A.getMqlReadUrl()+"?queries="+encodeURIComponent(C);
var K=function(L){if(L.q1.code=="/api/status/error"){if(typeof G=="function"){G(L.q1.messages[0].message,J);
}}else{F(L.q1);
}};
var H=function(){if(typeof G=="function"){G("Unknown",J);
}};
I.call(D,K,H,E);
};
A.read=function(E,F,D,C){A.readThroughQueue(A.getJsonpQueue(),E,F,D,C);
};
A.makeQueryNodeOptionalIfEmpty=function(C){var D=false;
for(var E in C){if(C.hasOwnProperty(E)){D=true;
break;
}}if(!D){C["optional"]=true;
}};
})();


/* path.js */
(function(){var B=window.MetawebSuite;
var A=B.freebase.PropertyPath=function(){this._segments=[];
};
A.createForwardPath=function(E){var C=new A();
for(var D=0;
D<E.length;
D++){C.appendSegment(E[D],true);
}return C;
};
A.parseString=function(K){var D=new A();
var E=0;
while(E<K.length-1){var F=K.charAt(E);
var G;
if(F=="."){G=true;
}else{if(F=="!"){G=false;
}else{throw new Error("Invalid property path string: "+K);
}}var C=K.indexOf(".",E+1);
var I=K.indexOf("!",E+1);
var H;
if(C>=0){if(I>=0&&I<C){H=I;
}else{H=C;
}}else{if(I>=0){H=I;
}else{H=K.length;
}}var J=K.substring(E+1,H);
D.appendSegment(J,G);
E=H;
}return D;
};
A.prototype.clone=function(){var C=new A();
for(var D=0;
D<this._segments.length;
D++){var E=this._segments[D];
C._segments.push({propertyID:E.propertyID,forward:E.forward});
}return C;
};
A.prototype.forEachSegment=function(D){for(var C=0;
C<this._segments.length;
C++){D(this._segments[C],C);
}};
A.prototype.forEachSegmentBackward=function(D){for(var C=this._segments.length-1;
C>=0;
C--){D(this._segments[C],C);
}};
A.prototype.getSegmentCount=function(){return this._segments.length;
};
A.prototype.getSegment=function(C){var D=this._internalGetSegment(C);
if(D!=null){return{propertyID:D.propertyID,forward:D.forward};
}else{return null;
}};
A.prototype._internalGetSegment=function(C){return(C>=0&&C<this._segments.length)?this._segments[C]:null;
};
A.prototype.getLastSegment=function(){return this.getSegment(this._segments.length-1);
};
A.prototype.getLastPropertyID=function(){var C=this._internalGetSegment(this._segments.length-1);
return C!=null?C.propertyID:null;
};
A.prototype.appendSegment=function(D,C){this._segments.push({propertyID:D,forward:C});
};
A.prototype.toString=function(){var C=[];
for(var D=0;
D<this._segments.length;
D++){var E=this._segments[D];
C.push(E.forward?".":"!");
C.push(E.propertyID);
}return C.join("");
};
A.segmentToForwardMqlKey=function(C){return(C.forward)?C.propertyID:("!"+C.propertyID);
};
A.segmentToBackwardMqlKey=function(C){return(!C.forward)?C.propertyID:("!"+C.propertyID);
};
A.pathToJSON=function(G){var F=[];
for(var C=0;
C<G._segments.length;
C++){var E=G._segments[C];
var D={p:E.propertyID};
if(E.forward){D.f=1;
}F.push(D);
}return F;
};
A.jsonToPath=function(D){var F=new A();
for(var C=0;
C<D.length;
C++){var E=D[C];
F.appendSegment(E.p,"f" in E&&E.f==1);
}return F;
};
A.createForwardPathIterator=function(F){var C=[];
for(var D=0;
D<F._segments.length;
D++){var E=F._segments[D];
C.push(A.segmentToForwardMqlKey(E));
}var G=function(J,K,M){if(K<C.length){var I=C[K];
if(I in J){var H=J[I];
for(var L=0;
L<H.length;
L++){G(H[L],K+1,M);
}}}else{M(J);
}};
return function(H,I){G(H,0,I);
};
};
A.extendQueryNodeWithPath=function(D,I,E){if(E==undefined){E=true;
}for(var F=0;
F<I._segments.length;
F++){var G=I._segments[F];
var C=A.segmentToForwardMqlKey(G);
var H;
if(C in D){H=D[C][0];
if("return" in H){delete H["return"];
}}else{H={};
if(E){H["optional"]=true;
}D[C]=[H];
}D=H;
}return D;
};
A.extractProxyPath=function(L){var J=new A();
var F=0;
while(true){var D=true;
for(var C=0;
C<L.length;
C++){if(F>=L[C].getSegmentCount()){D=false;
break;
}}if(!D){break;
}var H=L[0].getSegment(F);
var K=H.propertyID;
var G=H.forward;
var I=true;
for(var C=1;
C<L.length;
C++){var E=L[C].getSegment(F);
if(E.propertyID!=K||H.forward!=G){I=false;
break;
}}if(I){J.appendSegment(K,G);
}else{break;
}F++;
}return J;
};
A.removeProxyPath=function(H,E){var G=new A();
var D=0;
for(;
D<H.getSegmentCount()&&D<E.getSegmentCount();
D++){var F=H.getSegment(D);
var C=E.getSegment(D);
if(F.propertyID==C.propertyID&&F.forward==C.forward){G.appendSegment(F.propertyID,F.forward);
}else{break;
}}return G;
};
})();


/* schemas.js */
(function(){var G=window.MetawebSuite;
var C=G.freebase.schemas={_typeRecords:{},_propertyRecords:{}};
var F={"/type/int":true,"/type/float":true,"/type/boolean":true,"/type/rawstring":true,"/type/uri":true,"/type/datetime":true,"/type/bytestring":true,"/type/key":true,"/type/value":true,"/type/text":true,"/type/enumeration":true};
C.isNativeType=function(H){return H in F;
};
C.getPropertyRecord=function(H){return C._propertyRecords[H];
};
C.hasPropertyRecord=function(H){return H in C._propertyRecords;
};
C.getTypeRecord=function(H){return C._typeRecords[H];
};
C.hasTypeRecord=function(H){return H in C._typeRecords;
};
C.getContainingTypeOfProperty=function(I){var H=C.getContainingTypeIDOfProperty(I);
if(H!=null&&H in C._typeRecords){return C._typeRecords[H];
}return null;
};
C.getContainingTypeIDOfProperty=function(I){var H=I.lastIndexOf("/");
if(H>0){return I.substr(0,H);
}return null;
};
C.projectTopicsToTypes=function(H,J,I){H["return"]="estimate-count";
G.freebase.mql.read([{"id":null,"type":"/type/type","/type/type/instance":[H]}],function(N){var M=[];
for(var K=0;
K<N.result.length;
K++){var L=N.result[K];
if(typeof L=="object"){M.push({id:L.id,count:("/type/type/instance" in L&&L["/type/type/instance"].length>0)?L["/type/type/instance"][0]:0});
}}J(M);
},I);
};
C.projectTopicsToTypesPreloadSchemas=function(H,J,I){C.projectTopicsToTypes(H,function(O){var N=[];
for(var M=0;
M<O.length;
M++){var L=O[M].id;
if(!(L in C._typeRecords)){N.push(L);
}}var K=function(){J(O);
};
if(N.length>0){C.getTypeSchemas(N,K,I);
}else{K();
}},I);
};
C.getTypeSchemas=function(J,L,H){var K=0;
var I=function(){if(K<J.length){var N=Math.min(K+10,J.length);
var M=J.slice(K,N);
K=N;
E(M,I,H);
}else{L();
}};
I();
};
C.getPropertySchemas=function(K,J){var I=0;
var H=function(){if(I<K.length){var M=Math.min(I+10,K.length);
var L=K.slice(I,M);
I=M;
B(L,H);
}else{J();
}};
H();
};
var E=function(I,J,H){G.freebase.mql.read([{"id|=":I,"id":null,"name":null,"/type/type/properties":[{"id":null,"name":null,"master_property":null,"unique":null,"expected_type":[{"id":null,"name":null,"/freebase/type_hints/mediator":null}]}]}],function(Q){var P={};
var K=Q.result;
for(var N=0;
N<K.length;
N++){var O=K[N];
var L={id:O.id,name:O.name,properties:[],pivotSuggestions:[],filterSuggestions:[]};
C._typeRecords[O.id]=L;
var M=O["/type/type/properties"];
D(M,L,P);
}A(P,J,H);
},H);
};
var B=function(K,J,H){var I=[{"id":K,"name":null,"expected_type":[{"id":null,"name":null,"/freebase/type_hints/mediator":null}],"master_property":null,"unique":null}];
G.freebase.mql.read(I,function(M){var L={};
D(M.result,{},L);
A(L,J,H);
},H);
};
var D=function(L,I,M){for(var J=0;
J<L.length;
J++){var H=L[J];
var N={id:H.id,name:H.name,cvt:false,expectedType:null,expectedTypeLabel:null,masterProperty:H.master_property,unique:false};
C._propertyRecords[H.id]=N;
I.properties.push(H.id);
if("unique" in H){N.unique=H.unique;
}if("expected_type" in H&&H.expected_type.length>0){var K=H.expected_type[0];
N.expectedType=K.id;
N.expectedTypeLabel=K.name;
N.cvt=K["/freebase/type_hints/mediator"]==true;
if(!C.hasTypeRecord(K.id)&&N.cvt){M[K.id]=true;
}}}};
var A=function(I,L,H){var K=[];
for(var J in I){K.push(J);
}if(K.length>0){E(K,L,H);
}else{L();
}};
C.tryGetTypeLabel=function(L,I){if("getTypeID" in L){var N=5;
var K=null;
var J=function(){if(K in C._typeRecords){var O=C._typeRecords[K].name;
I(O);
}else{N--;
if(N>0){window.setTimeout(J,1000);
}else{}}};
var M=5;
var H=function(){K=L.getTypeID();
if(K!=null){J();
}else{M--;
if(M>0){window.setTimeout(H,1000);
}else{}}};
H();
}};
C.tryGetPropertyLabel=function(I,H){if(I in C._propertyRecords){H(C._propertyRecords[I].name);
}else{G.freebase.mql.read([{"id":I,"name":null}],function(J){H(J.result[0].name);
},G.freebase.mql.error);
}};
})();


/* type-stack.js */
(function(){var B=window.MetawebSuite;
var A=B.freebase.TypeStack=function(C,D,E){this._queryNode=C;
this._includeNativeTypes=(D);
this._useCVTsAsIs=(E);
this._typeRecords=null;
this._currentTypeRecord=0;
this._processedProperties={};
};
A.prototype.dispose=function(){this._queryNode=null;
this._typeRecords=null;
};
A.prototype.getTypeCount=function(){return this._typeRecords!=null?this._typeRecords.length:0;
};
A.prototype.getAllDimensions=function(){var D=[];
if(this._typeRecords!=null){for(var C=0;
C<this._typeRecords.length;
C++){D=D.concat(this._typeRecords[C].dimensions);
}}return D;
};
A.prototype.runWhenInitialized=function(E){if(this._typeRecords!=null){E();
return false;
}else{var C=this;
var D=function(F){C._buildTypeRecords(F||[]);
C._builtTypeRecords=true;
E();
};
B.freebase.schemas.projectTopicsToTypesPreloadSchemas(this._queryNode,D);
return true;
}};
A.computeDimensions=function(D,L,F,O,K,G,N,J,H){var M=B.freebase.schemas.getPropertyRecord(O);
if(typeof M!="object"){return ;
}if(M.expectedType!=null&&(J||!B.freebase.schemas.isNativeType(M.expectedType))){var P=K.clone();
P.appendSegment(O,true);
if(!H&&M.expectedType.indexOf("/measurement_unit/")!=0&&M.cvt){var E=M.expectedType;
var C=B.freebase.schemas.getTypeRecord(E);
if(C==null){return ;
}A._computeNestedDimensions(D,L,E,M.masterProperty,P,G+C.name+"/",N,J);
}else{var I=new B.freebase.Dimension(P);
I.typeID=L;
I.label=M.name;
I.fullLabel=G+M.name;
I.expectedType=M.expectedType;
I.expectedTypeLabel=M.expectedTypeLabel;
I.count=0;
D.push(I);
}}};
A._computeNestedDimensions=function(C,J,H,N,I,D,M,G){var L=B.freebase.schemas.getTypeRecord(H).properties;
for(var F=0;
F<L.length;
F++){var O=L[F];
var K=B.freebase.schemas.getPropertyRecord(O);
var E=K!=null&&K.unique;
if(O in M||(O==N&&E)){continue;
}M[O]=true;
A.computeDimensions(C,J,H,O,I,D,M,G,true);
}};
A.buildTypeRecord=function(G,C,J,F,D){var E=B.freebase.schemas.getTypeRecord(G);
if(E){var I=E.properties;
for(var H=0;
H<I.length;
H++){var K=I[H];
if(!(K in J)){J[K]=true;
A.computeDimensions(C,G,G,K,new B.freebase.PropertyPath(),"",J,F,D);
}}}};
A.prototype._buildTypeRecords=function(E){this._typeRecords=[];
for(var D=0;
D<E.length;
D++){var F=E[D];
if(B.freebase.schemas.hasTypeRecord(F.id)&&F.id!="/common/topic"){var C={typeID:F.id,count:F.count,dimensions:[],processedDimensions:0};
A.buildTypeRecord(F.id,C.dimensions,this._processedProperties,this._includeNativeTypes,this._useCVTsAsIs);
if(C.dimensions.length>0){this._typeRecords.push(C);
}}}this._typeRecords.sort(function(H,G){var I=G.count-H.count;
if(I==0){I=H.typeID.localeCompare(G.typeID);
}return I;
});
};
A.prototype.runOnDimensionsOfNextType=function(D){var C=this;
if(this._typeRecords!=null){return this._internalRunOnDimensionsOfNextType(D);
}else{this.runWhenInitialized(function(){C._internalRunOnDimensionsOfNextType(D);
});
return true;
}};
A.prototype._internalRunOnDimensionsOfNextType=function(H){if(this._currentTypeRecord<this._typeRecords.length){var D=this._typeRecords[this._currentTypeRecord];
var C=this;
var G=this._queryNode;
var I=function(){D.processedDimensions++;
if(D.processedDimensions>=D.dimensions.length){C._currentTypeRecord++;
H(D,D.dimensions);
}};
var F=function(K){var J=B.system.clone(G);
K.getPath().forEachSegment(function(L){var M={};
M[B.freebase.PropertyPath.segmentToBackwardMqlKey(L)]=[J];
J=M;
});
J["return"]=D.count>1000?"estimate-count":"count";
B.freebase.mql.read([J],function(L){K.count=L.result[0];
I();
},I);
};
for(var E=0;
E<D.dimensions.length;
E++){F(D.dimensions[E]);
}return true;
}else{return false;
}};
})();


/* parser.js */
(function(){var B=window.MetawebSuite;
var A=B.freebase.PathExpression={};
A.parse=function(E,G,C){G=G||0;
C=C||{};
var D=new A.Scanner(E,G);
try{var F=A._internalParse(D,null);
C.expression=F;
return F;
}finally{C.index=D.token()!=null?D.token().start:D.index();
}};
A.parseForContext=function(G,C,I,E){I=I||0;
E=E||{};
var F=new A.Scanner(G,I);
try{var D={index:C};
var H=A._internalParse(F,D);
E.expression=H;
return D;
}finally{E.index=F.token()!=null?F.token().start:F.index();
}};
A._internalParse=function(K,F){var C=A.Scanner;
var J=K.token();
var L=function(){K.next();
J=K.token();
};
var N=function(){return J!=null?J.start:K.index();
};
var O=function(){if(J==null){if(F!=null){return null;
}else{throw new Error("Missing factor at end of expression");
}}var P=null;
if(J.type==C.NUMBER||J.type==C.STRING||J.type==C.FREEBASE_ID){switch(J.type){case C.NUMBER:P=new A._Constant(J.value,"number");
break;
case C.STRING:P=new A._Constant(J.value,"string");
break;
case C.FREEBASE_ID:P=new A._Constant(J.value,"freebase-id");
break;
}if(F!=null){if(F.index>J.start&&F.index<=J.end){F.token=J;
F.type="generic";
}}L();
}else{switch(J.type){case C.IDENTIFIER:var R=J.value;
if(F!=null){if(F.index>J.start&&F.index<=J.end){F.token=J;
F.type="generic";
}}L();
if(R in A.Controls){if(J!=null&&J.type==C.DELIMITER&&J.value=="("){var U=J.end;
L();
if(F!=null){if(F.index>=U&&(J==null||F.index<=J.start)){F.token=J;
F.type="control";
F.identifier=R;
F.elementIndex=0;
}}var Q=(J!=null&&J.type==C.DELIMITER&&J.value==")")?[]:G("control",R,0);
P=new A._ControlCall(R,Q);
if(J!=null&&J.type==C.DELIMITER&&J.value==")"){var T=J.end;
L();
if(F!=null){if(F.index>=T&&(J==null||F.index<=J.start)){F.token=J;
F.type="generic";
}}}else{if(F==null){throw new Error("Missing ) to end "+R+" at position "+N());
}}}else{throw new Error("Missing ( to start "+R+" at position "+N());
}}else{if(J!=null&&J.type==C.DELIMITER&&J.value=="("){var U=J.end;
L();
if(F!=null){if(F.index>=U&&(J==null||F.index<=J.start)){F.token=J;
F.type="function";
F.identifier=R;
F.elementIndex=0;
}}var Q=(J!=null&&J.type==C.DELIMITER&&J.value==")")?[]:G("function",R,0);
P=new A._FunctionCall(R,Q);
if(J!=null&&J.type==C.DELIMITER&&J.value==")"){var T=J.end;
L();
if(F!=null){if(F.index>=T&&(J==null||F.index<=J.start)){F.token=J;
F.type="generic";
}}}else{if(F==null){throw new Error("Missing ) after function call "+R+" at position "+N());
}}}else{if(R=="true"){P=new A._Constant(true,"boolean");
}else{if(R=="false"){P=new A._Constant(false,"boolean");
}else{P=new A._Constant(R,"identifier");
}}}}break;
case C.DELIMITER:if(J.value=="("){var U=J.end;
L();
if(F!=null){if(F.index>=U&&(J==null||F.index<=J.start)){F.token=J;
F.type="generic";
}}P=D();
if(J!=null&&J.type==C.DELIMITER&&J.value==")"){L();
break;
}else{if(F==null){throw new Error("Missing ) at position "+N());
}}}else{if(J.value=="["){var U=J.end;
L();
if(F!=null){if(F.index>=U&&(J==null||F.index<=J.start)){F.token=J;
F.type="generic";
}}var S=(J!=null&&J.type==C.DELIMITER&&J.value=="]")?[]:G("generic",null);
P=new A._ConstantArray(S);
if(J!=null&&J.type==C.DELIMITER&&J.value=="]"){L();
break;
}else{if(F==null){throw new Error("Missing ] at end of array at position "+N());
}}}}default:if(F==null){throw new Error("Unexpected text "+J.value+" at position "+N());
}}}return P;
};
var M=function(){var R=O();
while(J!=null&&J.type==C.OPERATOR&&J.value=="."){var T=J.end;
L();
if(J==null||(J.type!=C.IDENTIFIER&&J.type!=C.FREEBASE_ID)){if(F!=null){if(F.index>=T&&(J==null||F.index<=J.start)){F.type="chain";
}break;
}else{throw new Error("Missing function name or Freebase ID at position "+N());
}}if(F!=null){if(F.index>=T&&(J==null||F.index<=J.end)){F.token=J;
F.type="chain";
}}if(J.type==C.IDENTIFIER){var Q=J.value;
L();
if(J==null||J.type!=C.DELIMITER||J.value!="("){if(F==null){throw new Error("Missing ( at position "+N());
}else{break;
}}var S=J.end;
L();
if(F!=null){if(F.index>=S&&(J==null||F.index<=J.start)){F.token=J;
F.type="function";
F.identifier=Q;
F.elementIndex=1;
}}var P=(J!=null&&J.type==C.DELIMITER&&J.value==")")?[]:G("function",Q,1);
P.unshift(R);
R=new A._FunctionCall(Q,P);
if(J==null||J.type!=C.DELIMITER||J.value!=")"){if(F==null){throw new Error("Missing ) at position "+N());
}else{break;
}}L();
}else{R=new A._FunctionCall("pivot",[R,O()]);
}}return R;
};
var E=function(){var Q=M();
while(J!=null&&J.type==C.OPERATOR&&(J.value=="*"||J.value=="/")){var R=J.end;
var P=J.value;
L();
if(F!=null){if(F.index>=R&&(J==null||F.index<=J.start)){F.token=J;
F.type="operator";
F.operator=P;
}}Q=new A._Operator(P,[Q,M()]);
}return Q;
};
var I=function(){var Q=E();
while(J!=null&&J.type==C.OPERATOR&&(J.value=="+"||J.value=="-")){var R=J.end;
var P=J.value;
L();
if(F!=null){if(F.index>=R&&(J==null||F.index<=J.start)){F.token=J;
F.type="operator";
F.operator=P;
}}Q=new A._Operator(P,[Q,E()]);
}return Q;
};
var D=function(){var R=I();
while(J!=null&&J.type==C.OPERATOR&&(J.value=="="||J.value=="<>"||J.value=="<"||J.value=="<="||J.value==">"||J.value==">=")){var Q=J.end;
var P=J.value;
L();
if(F!=null){if(F.index>=Q&&(J==null||F.index<=J.start)){F.token=J;
F.type="operator";
F.operator=P;
}}R=new A._Operator(P,[R,I()]);
}return R;
};
var H=function(P,Q,R){var T=N();
var U=J;
var S=D();
if(F!=null){if(S!=null&&S.getValueType()=="identifier"&&S instanceof A._Constant&&F.index>=T&&(J==null||F.index<=J.start)){F.token=U;
F.type=P;
if(Q!=null){F.identifier=Q;
F.elementIndex=R;
}}}return S;
};
var G=function(P,R,Q){var T=0;
var S=[H(P,R,Q)];
while(J!=null&&J.type==C.DELIMITER&&J.value==","){var U=J.end;
T++;
L();
if(F!=null){if(F.index>=U&&(J==null||F.index<=J.start)){F.token=J;
F.type=P;
if(R!=null){F.identifier=R;
F.elementIndex=T+Q;
}}}S.push(H(P,R,Q+T));
}return S;
};
return new A._Impl(D());
};
A.Scanner=function(D,C){this._text=D+" ";
this._maxIndex=D.length;
this._index=C;
this.next();
};
A.Scanner.DELIMITER=0;
A.Scanner.NUMBER=1;
A.Scanner.STRING=2;
A.Scanner.OPERATOR=3;
A.Scanner.IDENTIFIER=4;
A.Scanner.FREEBASE_ID=5;
A.Scanner.prototype.token=function(){return this._token;
};
A.Scanner.prototype.index=function(){return this._index;
};
A.Scanner._lowercaseLetters="abcdefghijklmnopqrstuvwxyz";
A.Scanner.prototype.next=function(){this._token=null;
while(this._index<this._maxIndex&&" \t\r\n".indexOf(this._text.charAt(this._index))>=0){this._index++;
}if(this._index<this._maxIndex){var E=this._text.charAt(this._index);
var D=this._text.charAt(this._index+1);
if("<>".indexOf(E)>=0){if((D=="=")||("<>".indexOf(D)>=0&&E!=D)){this._token={type:A.Scanner.OPERATOR,value:E+D,start:this._index,end:this._index+2};
this._index+=2;
}else{this._token={type:A.Scanner.OPERATOR,value:E,start:this._index,end:this._index+1};
this._index++;
}}else{if(E=="/"&&A.Scanner._lowercaseLetters.indexOf(D)>=0){var C=this._index;
while(C<this._maxIndex){var F=this._text.charAt(C).toLowerCase();
if(A.Scanner._lowercaseLetters.indexOf(F)>=0||F=="_"||F=="/"){C++;
}else{break;
}}this._token={type:A.Scanner.FREEBASE_ID,value:this._text.substring(this._index,C),start:this._index,end:C};
this._index=C;
}else{if("+-*/=.".indexOf(E)>=0){this._token={type:A.Scanner.OPERATOR,value:E,start:this._index,end:this._index+1};
this._index++;
}else{if("()[],".indexOf(E)>=0){this._token={type:A.Scanner.DELIMITER,value:E,start:this._index,end:this._index+1};
this._index++;
}else{if("\"'".indexOf(E)>=0){var C=this._index+1;
while(C<this._maxIndex){if(this._text.charAt(C)==E&&this._text.charAt(C-1)!="\\"){break;
}C++;
}if(C<this._maxIndex){this._token={type:A.Scanner.STRING,value:this._text.substring(this._index+1,C).replace(/\\'/g,"'").replace(/\\"/g,'"'),start:this._index,end:C+1};
this._index=C+1;
}else{throw new Error("Unterminated string starting at "+this._index);
}}else{if(this._isDigit(E)){var C=this._index;
while(C<this._maxIndex&&this._isDigit(this._text.charAt(C))){C++;
}if(C<this._maxIndex&&this._text.charAt(C)=="."){C++;
while(C<this._maxIndex&&this._isDigit(this._text.charAt(C))){C++;
}}this._token={type:A.Scanner.NUMBER,value:parseFloat(this._text.substring(this._index,C)),start:this._index,end:C};
this._index=C;
}else{var C=this._index;
while(C<this._maxIndex){var F=this._text.charAt(C);
if("()[],.!@\t".indexOf(F)<0){C++;
}else{break;
}}this._token={type:A.Scanner.IDENTIFIER,value:jQuery.trim(this._text.substring(this._index,C)),start:this._index,end:C};
this._index=C;
}}}}}}}};
A.Scanner.prototype._isDigit=function(C){return"0123456789".indexOf(C)>=0;
};
})();


/* controls.js */
(function(){var B=window.MetawebSuite;
var A=B.freebase.PathExpression;
A.Controls={};
})();


/* evaluator.js */
(function(){var B=window.MetawebSuite;
var A=B.freebase.PathExpression;
A._Impl=function(C){this._rootNode=C;
};
A._Impl.prototype.evaluate=function(D,F,E){this._rootNode.prepare();
var C=this;
A.SchemaManager.processQueues(function(){C._rootNode.evaluate(D,function(G){if("query" in G){A.Util.evaluateIntermediateToTerminal(G,F,E);
}else{F(G);
}},E);
});
};
A._Impl.prototype.evaluateWithExtenders=function(F,H,I,C,E){try{this._rootNode.prepare();
for(var D in H){var J=H[D];
J._rootNode.prepare();
}for(var D in I){var J=I[D];
J._rootNode.prepare();
}var K=this;
A.SchemaManager.processQueues(function(){K._rootNode.evaluate(F,function(P){var O={};
var Q={};
var M=[];
for(var S in H){var R=H[S];
var L=R.extend(F,P,false);
O[S]=L;
M.push(L);
}for(var S in I){var R=I[S];
var L=R.extend(F,P,true);
Q[S]=L;
M.push(L);
}var N=function(T){A.Util.postProcessAccessors(M,T,function(U){C(U,O,Q);
},E);
};
if("query" in P){A.Util.evaluateIntermediateToTerminal(P,N,E);
}else{N(P,O,Q);
}},E);
});
}catch(G){log(G);
}};
A._Impl.prototype.extend=function(E,D,C){return this._rootNode.extend(E,D,C);
};
A._Constant=function(D,C){this._value=D;
this._valueType=C;
};
A._Constant.prototype.getValueType=function(){return this._valueType;
};
A._Constant.prototype.getValue=function(){return this._value;
};
A._Constant.prototype.prepare=function(){};
A._Constant.prototype.evaluate=function(C,E,D){E({valueType:this._valueType,values:[this._value]});
};
A._Constant.prototype.extend=function(G,F,E){if(this._valueType=="identifier"){if(this._value=="thing"){var H={access:function(I){return[I];
},needsPostProcessing:false};
if("query" in F){H["query"]=F.query;
}else{H["result"]=F;
}return H;
}else{var D=G[this._value];
return{result:D,access:function(I){return[D];
},needsPostProcessing:false};
}}else{var C=this;
return{result:{valueType:this._valueType,values:[this._value]},access:function(I){return[{value:C._value}];
},needsPostProcessing:false};
}};
A._ConstantArray=function(C){this._elements=C;
};
A._ConstantArray.prototype.getElements=function(){return[].concat(this._elements);
};
A._ConstantArray.prototype.prepare=function(){for(var C=0;
C<this._elements.length;
C++){this._elements[C].prepare();
}};
A._ConstantArray.prototype.evaluate=function(C,E,D){A.Util.evaluateArguments(this._elements,C,function(H){var J=null;
var F=[];
for(var G=0;
G<H.length;
G++){var I=H[G];
if("query" in I){D("array cannot contain query arguments");
return ;
}if(I.values.length>0){if(J==null){J=I.valueType;
}else{if(J!=I.valueType){D("array cannot contain elements of different types");
return ;
}}F=F.concat(I.values);
}}E({valueType:J,values:F});
},D);
};
A._ConstantArray.prototype.extend=function(F,E,D){var G=this._elements;
var C=[];
var H=A.Util.extendMany(F,E,D,G,C);
return{needsPostProcessing:H,postProcess:function(I,K,J){A.Util.postProcessAccessors(C,I,K,J);
},access:function(I){var J=[];
var M=null;
for(var K=0;
K<C.length;
K++){var L=C[K].access(I);
if(L!=null){if(M==null){M=L.valueType;
}else{if(M!=L.valueType){throw new Error("Elements in constant array have different types");
}}J=J.concat(L.values);
}}return{valueType:M,values:J};
}};
};
A._ControlCall=function(D,C){this._identifier=D;
this._args=C;
};
A._ControlCall.prototype.prepare=function(){throw new Error("Not implemented");
};
A._ControlCall.prototype.evaluate=function(C,E,D){throw new Error("Not implemented");
};
A._ControlCall.prototype.extend=function(E,D,C){throw new Error("Not implemented");
};
A._FunctionCall=function(D,C){this._identifier=D;
this._args=C;
};
A._FunctionCall.prototype.prepare=function(){for(var C=0;
C<this._args.length;
C++){this._args[C].prepare();
}var D=A.Functions[this._identifier];
if("prepare" in D){D.prepare(this._args);
}};
A._FunctionCall.prototype.evaluate=function(C,F,D){var E=A.Functions[this._identifier];
A.Util.evaluateArguments(this._args,C,function(G){E.evaluate(G,C,F,D);
},D);
};
A._FunctionCall.prototype.extend=function(E,D,C){var F=A.Functions[this._identifier];
if("extend" in F){return F.extend(E,D,C,this._args);
}else{throw new Error("Function does not implement extend");
}};
A._Operator=function(C,D){this._operator=C;
this._args=D;
};
A._Operator.prototype.prepare=function(){throw new Error("Not implemented");
};
A._Operator.prototype.evaluate=function(C,E,D){throw new Error("Not implemented");
};
A._Operator.prototype.extend=function(E,D,C){throw new Error("Not implemented");
};
A.SchemaManager={_properties:{},_queuedProperties:{}};
A.SchemaManager.queueProperty=function(C){if(!(C in A.SchemaManager._properties)&&C!="/type/object"){A.SchemaManager._queuedProperties[C]=true;
}};
A.SchemaManager.getPropertyRecord=function(C){return A.SchemaManager._properties[C];
};
A.SchemaManager.processQueues=function(F){var E=[];
for(var D in A.SchemaManager._queuedProperties){E.push(D);
}A.SchemaManager._queuedProperties={};
if(E.length>0){var C=[{"id|=":E,"id":null,"type":"/type/property","expected_type":[{"id":null,"optional":true}]}];
B.freebase.mql.read(C,function(G){A.SchemaManager._gotPropertySchemas(G,F);
},function(G){B.system.error(G);
F();
});
}else{F();
}};
A.SchemaManager._gotPropertySchemas=function(E,G){var D=E.result;
for(var C=0;
C<D.length;
C++){var F=D[C];
A.SchemaManager._properties[F.id]=F;
}G();
};
A.Util={evaluateArguments:function(E,H,J,I){var C=0;
var F=[];
var D=function(K){F.push(K);
G();
};
var G=function(){if(C<E.length){var K=E[C++];
K.evaluate(H,D,I);
}else{J(F);
}};
G();
},evaluateArgumentsToTerminals:function(F,H,J,I){var C=0;
var E=[];
var D=function(K){F.push(K);
G();
};
var G=function(){if(C<F.length){var K=F[C++];
if("query" in K){A.Util.evaluateIntermediateToTerminal(K,function(L){E.push(L);
G();
},I);
}else{E.push(K);
G();
}}else{J(E);
}};
G();
},evaluateIntermediateToTerminal:function(C,E,D){C.prepareToQuery();
B.freebase.mql.read(C.query,function(F){E(C.parseResult(F.result));
},D);
},queryMany:function(E,I,H){var C=0;
var F=[];
var D=function(J){argIntermediates.push(J);
G();
};
var G=function(){if(C<E.length){var J=E[C++];
B.freebase.mql.read(J,function(K){F.push(K.result);
G();
},function(L,K){H(L,K);
});
}else{I(F);
}};
G();
},postProcessAccessors:function(E,F,H,G){var C=0;
var D=function(){while(C<E.length){var I=E[C++];
if(I.needsPostProcessing){I.postProcess(F,D,G);
return ;
}}H(F);
};
D();
},extendMany:function(J,E,K,C,I){var D=false;
for(var G=0;
G<C.length;
G++){var H=C[G];
var F=H.extend(J,E,K);
if(F.needsPostProcessing){D=true;
}I.push(F);
}return D;
}};
})();


/* functions.js */
(function(){var B=window.MetawebSuite;
var A=B.freebase.PathExpression;
A.Functions={};
A.Types={Set:0,TopicID:1,TypeID:2,PropertyID:3,String:4,Number:5,Boolean:6,ConstantArray:7};
A.Functions["instances"]={argumentTypes:[{type:A.Types.TypeID}],returnType:{type:A.Types.Set},evaluate:function(C,E,H,F){var G=[{}];
var D={query:G,valueType:"topic",prepareToQuery:function(){G[0]["id"]=null;
G[0]["name"]=null;
},parseResult:function(I){return{values:I,valueType:"topic"};
}};
if(C.length==1&&"query" in C[0]){G[0]["type"]=C[0].query;
H(D);
}else{A.Util.evaluateArgumentsToTerminals(C,E,function(L){var M=[];
for(var K=0;
K<L.length;
K++){var N=L[K];
if(N.valueType=="topic"){var I=N.values;
for(var J=0;
J<I.length;
J++){M.push(I[J].id);
}}else{if(N.valueType=="freebase-id"){M=M.concat(N.values);
}}}G[0]["type|="]=M;
H(D);
},F);
}}};
A.Functions["topic"]={argumentTypes:[{type:A.Types.TopicID}],returnType:{type:A.Types.Set},evaluate:function(C,E,H,F){var G=[{}];
var D={query:G,valueType:"topic",prepareToQuery:function(){G[0]["id"]=null;
G[0]["name"]=null;
},parseResult:function(I){return{values:I,valueType:"topic"};
}};
A.Util.evaluateArgumentsToTerminals(C,E,function(M){var I=[];
for(var L=0;
L<M.length;
L++){var N=M[L];
if(N.valueType=="topic"){var J=N.values;
for(var K=0;
K<J.length;
K++){I.push(J[K].id);
}}else{if(N.valueType=="freebase-id"){I=I.concat(N.values);
}}}G[0]["id|="]=I;
H(D);
},F);
}};
A.Functions["count"]={argumentTypes:[{type:A.Types.Set}],returnType:{type:A.Types.Number},evaluate:function(D,I,C,H){var K=0;
var G=[];
for(var F=0;
F<D.length;
F++){var E=D[F];
if("query" in E){E.prepareToQuery();
var J=E.query;
J[0]["return"]="count";
G.push(J);
}else{K+=E.values.length;
}}if(G.length==0){C({valueType:"number",values:[K]});
}else{A.Util.queryMany(G,function(N){for(var M=0;
M<N.length;
M++){var L=N[M];
if(L.length>0){K+=L[0];
}}C({valueType:"number",values:[K]});
},H);
}}};
A.Functions["group"]={argumentTypes:[{type:A.Types.Set},{type:A.Types.PropertyID}],returnType:{type:A.Types.Set},evaluate:function(F,I,D,H){if(F.length<2){H("group function expects 2 arguments");
}var E=F[0];
var P=F[1];
if(P.valueType!="freebase-id"){H("group function expects its second argument to be a Freebase ID");
return ;
}if("query" in E){var C=null;
var M=null;
var L=E.query[0];
var J=P.values;
for(var G=0;
G<J.length;
G++){var N=J[G];
var O="!"+N;
var K={};
K[O]=[L];
M=O;
C=L;
L=K;
}C["return"]="count";
D({query:[L],valueType:"complex",prepareToQuery:function(){L["id"]=null;
L["name"]=null;
},parseResult:function(T){var R=[];
for(var S=0;
S<T.length;
S++){var Q=T[S];
Q["count"]=Q[M][0];
R.push(Q);
}return{values:R,valueType:"complex"};
}});
}else{H("group function expects its first argument to be a query");
}}};
A.Functions["head"]={argumentTypes:[{type:A.Types.Set},{type:A.Types.PropertyID},{type:A.Types.Boolean},{type:A.Types.Number}],returnType:{type:A.Types.Set},evaluate:function(N,S,L,I){if(N.length<2){I("head function expects at least 2 arguments");
}var Q=N[0];
var P=N[1];
var K=3;
var C=true;
var J;
if(Q.valueType!="topic"&&Q.valueType!="complex"){I("head function expects its first argument to be return topics or complex objects");
return ;
}if((P.valueType!="string"&&P.valueType!="freebase-id")||P.values.length!=1){I("head function expects its second argument to be a string or a Freebase ID");
return ;
}else{J=P.values[0];
}if(N.length>2){var F=N[2];
if(F.valueType!="boolean"||F.values.length!=1){I("head function expects its third argument to be a boolean");
return ;
}C=F.values[0];
}if(N.length>3){var M=N[3];
if(M.valueType!="number"||M.values.length!=1){I("head function expects its fourth argument to be a number");
return ;
}K=M.values[0];
}if(J!="count"&&"query" in Q){var J=P.values[0];
var G=Q.query;
var R=G[0];
R["sort"]=(C?"":"-")+J;
R["limit"]=K;
if(!(J in R)){R[J]=null;
}L({query:G,valueType:Q.valueType,prepareToQuery:Q.prepareToQuery,parseResult:Q.parseResult});
}else{var D=function(V,U){var X=V[J];
var W=U[J];
return X.localeCompare(W);
};
var T=function(V,U){var X=V[J];
var W=U[J];
return X-W;
};
var E=(J=="count")?T:D;
var H=C?E:function(V,U){return E(U,V);
};
var O=function(U){U.values.sort(H);
L({valueType:U.valueType,values:U.values.slice(0,K)});
};
if("query" in Q){A.Util.evaluateArgumentsToTerminals([Q],S,function(U){O(U[0]);
},I);
}else{O(Q);
}}}};
A.Functions["tail"]={argumentTypes:[{type:A.Types.Set},{type:A.Types.PropertyID},{type:A.Types.Boolean},{type:A.Types.Number}],returnType:{type:A.Types.Set},evaluate:function(N,S,L,I){if(N.length<2){I("tail function expects at least 2 arguments");
}var Q=N[0];
var P=N[1];
var K=3;
var C=false;
var J;
if(Q.valueType!="topic"&&Q.valueType!="complex"){I("tail function expects its first argument to be return topics or complex objects");
return ;
}if((P.valueType!="string"&&P.valueType!="freebase-id")||P.values.length!=1){I("tail function expects its second argument to be a string or a Freebase ID");
return ;
}else{J=P.values[0];
}if(N.length>2){var F=N[2];
if(F.valueType!="boolean"||F.values.length!=1){I("tail function expects its third argument to be a boolean");
return ;
}C=!F.values[0];
}if(N.length>3){var M=N[3];
if(M.valueType!="number"||M.values.length!=1){I("tail function expects its fourth argument to be a number");
return ;
}K=M.values[0];
}if(J!="count"&&"query" in Q){var J=P.values[0];
var G=Q.query;
var R=G[0];
R["sort"]=(C?"":"-")+J;
R["limit"]=K;
if(!(J in R)){R[J]=null;
}L({query:G,valueType:Q.valueType,prepareToQuery:Q.prepareToQuery,parseResult:Q.parseResult});
}else{var D=function(V,U){var X=V[J];
var W=U[J];
return X.localeCompare(W);
};
var T=function(V,U){var X=V[J];
var W=U[J];
return X-W;
};
var E=(J=="count")?T:D;
var H=C?E:function(V,U){return E(U,V);
};
var O=function(U){U.values.sort(H);
L({valueType:U.valueType,values:U.values.slice(0,K)});
};
if("query" in Q){A.Util.evaluateArgumentsToTerminals([Q],S,function(U){O(U[0]);
},I);
}else{O(Q);
}}}};
A.Functions["sort"]={argumentTypes:[{type:A.Types.Set},{type:A.Types.PropertyID},{type:A.Types.Boolean}],returnType:{type:A.Types.Set},evaluate:function(H,L,E,K){if(H.length<2){K("sort function expects at least 2 arguments");
}var F=H[0];
var R=H[1];
var I=true;
var Q;
if(F.valueType!="topic"&&F.valueType!="complex"){K("sort function expects its first argument to be return topics or complex objects");
return ;
}if((R.valueType!="freebase-id"&&R.valueType!="string")||R.values.length!=1){K("sort function expects its second argument to be a string or a Freebase ID");
return ;
}else{Q=R.values[0];
}if(H.length>2){var G=H[2];
if(G.valueType!="boolean"||G.values.length!=1){K("sort function expects its fourth argument to be a boolean");
return ;
}I=G.values[0];
}if(Q!="count"&&"query" in F){var Q=R.values[0];
var M=F.query;
var N=M[0];
N["sort"]=(I?"":"-")+Q;
if(!(Q in N)){N[Q]=null;
}E({query:M,valueType:F.valueType,prepareToQuery:F.prepareToQuery,parseResult:F.parseResult});
}else{var D=function(T,S){var V=T[Q];
var U=S[Q];
return V.localeCompare(U);
};
var P=function(T,S){var V=T[Q];
var U=S[Q];
return V-U;
};
var O=(Q=="count")?P:D;
var C=I?O:function(T,S){return O(S,T);
};
var J=function(S){S.values.sort(C);
E(S);
};
if("query" in F){A.Util.evaluateArgumentsToTerminals([F],L,function(S){J(S[0]);
},K);
}else{J(F);
}}}};
A.Functions["pivot"]={argumentTypes:[{type:A.Types.Set},{type:A.Types.PropertyID}],returnType:{type:A.Types.Set},prepare:function(D){var C=D[1];
if(C instanceof A._Constant){A.SchemaManager.queueProperty(C.getValue());
}else{if(C instanceof A._ConstantArray){var G=C.getElements();
for(var F=0;
F<G.length;
F++){var E=G[F];
if(E instanceof A._Constant){A.SchemaManager.queueProperty(E.getValue());
}}}}},evaluate:function(E,I,C,H){if(E.length<2){H("pivot function expects 2 arguments");
}var D=E[0];
var M=E[1];
if(M.valueType!="freebase-id"||M.values.length<1){H("pivot function expects its second argument to be a Freebase ID");
return ;
}if("query" in D){var J=D.query[0];
var K;
for(var F=0;
F<M.values.length;
F++){K=M.values[F];
var L=(K.charAt(0)=="!")?K:("!"+K);
var G={};
G[L]=[J];
J=G;
}C({query:[J],valueType:"topic",prepareToQuery:function(){var N=A.SchemaManager.getPropertyRecord(K);
if(N!=null&&"expected_type" in N&&N.expected_type[0].id.indexOf("/type/")==0){J["value"]=null;
}else{J["id"]=null;
J["name"]=null;
}},parseResult:function(N){return{values:N,valueType:"topic"};
}});
}else{H("pivot function expects its first argument to be a query");
}},extend:function(J,E,L,K){var G=[];
var D=A.Util.extendMany(J,E,L,K,G);
if(D){throw new Error("pivot does not know how to extend when some of its arguments need post processing");
}if("query" in G[0]){var N=G[0].query;
if(N instanceof Array){N=N[0];
}}else{throw new Error("pivot does not know how to extend non-query sets");
}if("result" in G[1]){var C=G[1].result;
if(C.valueType=="freebase-id"){var H="p"+Math.floor(Math.random()*100);
var M=C.values[0];
var O=H+":"+M;
var F={};
var I=A.SchemaManager.getPropertyRecord(M);
if(I!=null&&"expected_type" in I&&I.expected_type[0].id.indexOf("/type/")==0){F["value"]=null;
}else{F["id"]=null;
F["name"]=null;
}if(L){F["optional"]=true;
}N[O]=[F];
}else{throw new Error("pivot does not know how to extend by something other than a property specified as a Freebase ID");
}}else{throw new Error("pivot does not know how to extend by a non-constant property");
}return{needsPostProcessing:D,query:N[O],postProcess:function(P,R,Q){throw new Error("pivot does not know how to post process yet");
},access:function(Q){var R=G[0].access(Q);
var V=[];
for(var T=0;
T<R.length;
T++){var U=R[T];
if(U!=null&&O in U){var P=U[O];
if(P!=null){for(var S=0;
S<P.length;
S++){V.push(P[S]);
}}}}return V;
}};
}};
A.Functions["filter"]={argumentTypes:[{type:A.Types.Set},{type:A.Types.PropertyID},{type:A.Types.TopicID}],returnType:{type:A.Types.Set},evaluate:function(E,I,C,H){if(E.length<3){H("filter function expects 3 arguments");
}var D=E[0];
var N=E[1];
if(N.valueType!="freebase-id"||N.values.length<1){H("filter function expects its second argument to be a Freebase ID");
return ;
}var J=E[2];
if(J.valueType!="freebase-id"||J.values.length<1){H("filter function expects its third argument to be a Freebase ID");
return ;
}if("query" in D){var K=D.query;
var L=K[0];
for(var F=0;
F<N.values.length;
F++){var M=N.values[F];
var G={};
L[M]=[G];
L=G;
}L["id|="]=J.values;
C({query:K,valueType:D.valueType,prepareToQuery:D.prepareToQuery,parseResult:D.parseResult});
}else{H("filter function expects its first argument to be a query");
}}};
A.Functions["geolocation"]={argumentTypes:[{type:A.Types.Set}],returnType:{type:A.Types.Set},evaluate:function(C,D,F,E){throw new Error("geolocation is only intended for extending, not for evaluating");
},extend:function(H,D,J,I){var F=[];
var C=A.Util.extendMany(H,D,J,I,F);
if(C){throw new Error("geolocation does not know how to extend when some of its arguments need post processing");
}if("query" in F[0]){var K=F[0].query;
if(K instanceof Array){K=K[0];
}}else{throw new Error("geolocation does not know how to extend non-query sets");
}var G="p"+Math.floor(Math.random()*100);
var L=G+":/location/location/geolocation";
var E={"/location/geocode/latitude":null,"/location/geocode/longitude":null};
if(J){E["optional"]=true;
}K[L]=[E];
return{needsPostProcessing:C,query:K[L],postProcess:function(M,O,N){throw new Error("geolocation does not know how to post process yet");
},access:function(N){var P=F[0].access(N);
var T=[];
for(var R=0;
R<P.length;
R++){var S=P[R];
if(L in S){var M=S[L];
if(M!=null){for(var Q=0;
Q<M.length;
Q++){var O=M[Q];
T.push({lat:O["/location/geocode/latitude"],lng:O["/location/geocode/longitude"]});
}}}}return T;
}};
}};
A.Functions["datediff"]={argumentTypes:[{type:A.Types.String},{type:A.Types.String}],returnType:{type:A.Types.Number},evaluate:function(C,D,F,E){throw new Error("datediff is only intended for extending, not for evaluating");
},extend:function(G,F,E,D){var C=[];
var I=A.Util.extendMany(G,F,E,D,C);
var H={needsPostProcessing:I,postProcess:function(J,L,K){A.Util.postProcessAccessors(C,J,L,K);
},access:function(R){var O=C[0].access(R);
var P=C[1].access(R);
var L=C[2].access(R);
var N=[];
if(L.length==1&&O.length==1&&P.length==1){var J=SimileAjax.DateTime.parseIso8601DateTime(O[0].value);
var M=SimileAjax.DateTime.parseIso8601DateTime(P[0].value);
if(J!=null&&M!=null){var K=M.getTime()-J.getTime();
var Q;
switch(L[0].value){case"year":Q=Math.floor(Math.abs(K)/31536000000);
break;
}N.push({value:Q});
}}return N;
}};
return H;
}};
})();


/* terminal.js */
window.MetawebSuite.system.onFinishLoadingPackage("metaweb-suite-freebase");


/* search-widgets-package.js */
(function() {
    var mw = window.MetawebSuite;
    mw.system.onStartLoadingNativePackage(
        "search-widgets",
        [   "../freebase-suggest/freebase.suggest.js",
            "parallax-search-widget.js",
            "terminal.js"
        ],
        [   "parallax-search-widget.css"
        ],
        function() {
            /*
             *  We can't package the freebase-suggest CSS because then all the 
             *  relative paths to their images are no longer valid.
             */
            mw.system.addCsses(
                mw.system.nativePackageUrl + "search-widgets/freebase-suggest/css/",
                [   "freebase-controls.css"
                ]
            );
        }
    );
})();


/* search-widgets-bundle.js */


/* freebase.suggest.js */
if(!window.freebase){window.freebase={};
}if(!window.freebase.controls){window.freebase.controls={};
}(function(F,D){F.fn._freebaseInput=function(L,K){if(!K){K={};
}return this.attr("autocomplete","off").each(function(){L.release(this);
var M=this;
F.each(["focus","click"],function(O,P){F(M).unbind(P,L.delegate(P)).bind(P,L.delegate(P));
});
if(typeof this["fb_id"]=="undefined"){this.fb_id=L.counter++;
}L.cache[this.fb_id]=null;
var N={};
F.extend(N,L.default_options,K);
L.option_hash[this.fb_id]=N;
if(K.initialize){L.manage(this);
}});
};
D.log=D.error=D.debug=function(){};
if(typeof console!="undefined"&&console.log&&console.error){D.log=console.log;
D.error=console.error;
D.debug=console.debug;
}D.delegate=function(M,K,L){if(typeof L=="undefined"){L=[];
}var N=function(){var P=[];
for(var Q=0,O=arguments.length;
Q<O;
Q++){P.push(arguments[Q]);
}if(arguments.callee&&arguments.callee.fn){return(arguments.callee.fn.apply(arguments.callee.thisArg,arguments.callee.argArray.concat(P)));
}return undefined;
};
N.thisArg=K;
N.fn=M;
N.argArray=L;
return(N);
};
D.quote_id=function(K){if(K.charAt(0)=="/"){return K;
}else{return("/"+encodeURIComponent(K));
}};
D.state=function(){};
D.state.prototype={enter:function(K){},exit:function(K){},handle:function(K){}};
D.state_machine=function(L){this.current_state=null;
this.states={};
var K=this;
F.each(L,function(M,N){N[1].sm=K;
K.states[N[0]]=N[1];
if(M==0){K.current_state=N[0];
}});
if(!this.current_state){throw"StateMachine must be initialized with at least one state";
}this.states[this.current_state].enter();
};
D.state_machine.prototype={transition:function(O,N,P,L){var M=this.states[O];
if(!M){throw ("Unrecongized state:"+O);
}var K=this.states[this.current_state];
K.exit(N);
M.enter(P);
this.current_state=O;
this.handle(L);
},handle:function(K){if(K){this.states[this.current_state].handle(K);
}}};
D.InputControl=function(){this.default_options={};
this.counter=0;
this.cache={};
this.option_hash={};
this.sm=null;
this.delegates={};
this.dropdown_delay=30;
this.manage_delay=20;
this.release_delay=10;
};
D.InputControl.prototype={delegate:function(L,K){if(!this.delegates[L]){this.delegates[L]=D.delegate(this[L],this);
}this.delegates[L].argArray=K?K:[];
return this.delegates[L];
},options:function(K){var L=this.option_hash[K.fb_id];
if(!L){throw"Unknown input";
}return L;
},transition:function(K){if(this.sm){this.sm.transition(K);
}},handle:function(K){if(this.sm){this.sm.handle(K);
}},val:function(L){var K=F(L).val();
if(K==null){return"";
}return F.trim(K);
},name:function(K){if(K.text!=null){return K.text;
}if(K.name!=null){return K.name;
}return"unknown";
},delay:function(K){var L=0.3;
if(K>0){L=1/(6*(K-0.7))+0.3;
}return L*1000;
},manage:function(L){this.release(L);
var K=this;
F.each(["blur","keydown","keypress","keyup","input","paste"],function(M,N){F(L).bind(N,K.delegate(N));
});
this.transition("start");
this.manage_hook(L);
},manage_hook:function(K){},release:function(L){var K=this;
F.each(["blur","keydown","keypress","keyup","input","paste"],function(M,N){F(L).unbind(N,K.delegate(N));
});
this.transition("start");
this.release_hook(L);
},release_hook:function(K){},destroy:function(L){window.clearTimeout(this.manage_timeout);
window.clearTimeout(this.release_timeout);
window.clearTimeout(this.textchange_timeout);
window.clearTimeout(this.loadmsg_timeout);
var K=this;
F.each(["focus","click"],function(M,N){F(L).unbind(N,K.delegate(N));
});
this.release(L);
},focus:function(L){window.clearTimeout(this.manage_timeout);
var K=L.target;
try{this.options(K);
}catch(L){return ;
}this.manage_timeout=window.setTimeout(this.delegate("manage",[K]),this.manage_delay);
},blur:function(L){window.clearTimeout(this.release_timeout);
var K=F(L.target)[0];
if(this.dont_release){this._input=K;
return ;
}this.release_timeout=window.setTimeout(this.delegate("release",[K]),this.release_delay);
},keydown:function(K){switch(K.keyCode){case 9:this.tab(K);
break;
case 38:case 40:K.preventDefault();
break;
default:break;
}},keypress:function(K){switch(K.keyCode){case 38:case 40:if(!K.shiftKey){K.preventDefault();
}break;
case 13:this.enterkey(K);
break;
case 27:this.escapekey(K);
break;
default:break;
}},keyup:function(K){switch(K.keyCode){case 38:K.preventDefault();
this.uparrow(K);
break;
case 40:K.preventDefault();
this.downarrow(K);
break;
case 9:case 13:case 16:case 17:case 18:case 27:case 37:case 39:case 224:break;
default:this.textchange(K);
break;
}},click:function(K){},input:function(K){this.textchange(K);
},paste:function(K){this.textchange(K);
},uparrow:function(K){this.handle({id:"UPARROW",input:K.target});
},downarrow:function(K){this.handle({id:"DOWNARROW",input:K.target});
},tab:function(K){this.handle({id:"TAB",input:K.target,domEvent:K});
},enterkey:function(K){if(K.shiftKey){this.handle({id:"ENTERKEY-SHIFT",input:K.target,domEvent:K});
}else{this.handle({id:"ENTERKEY",input:K.target,domEvent:K});
}},escapekey:function(K){this.handle({id:"ESCAPEKEY",input:K.target});
},textchange:function(L){window.clearTimeout(this.textchange_timeout);
this.input_text=this.val(L.target);
var K=this.delay(this.input_text.length);
this.textchange_timeout=window.setTimeout(this.delegate("textchange_delay",[L.target]),K);
},textchange_delay:function(K){this.handle({id:"TEXTCHANGE",input:K});
}};
D.InputSelectControl=function(){D.InputControl.call(this);
this.min_len=1;
this.should_filter=true;
this.fudge=8;
this.loadmsg_delay=50;
this.sm=new D.state_machine([["start",new H(this)],["getting",new A(this)],["selecting",new E(this)]]);
};
D.InputSelectControl.prototype=new D.InputControl();
D.InputSelectControl.prototype.constructor=D.InputSelectControl;
var B=D.InputSelectControl.prototype;
B.get_list=function(){return F("#fbs_list > .fbs-bottomshadow > .fbs-ul")[0];
};
B.get_list_items=function(){return F(this.get_list()).children("li");
};
B.release_hook=function(K){this.list_hide();
};
B.click_listitem=function(K){this.handle({id:"LISTITEM_CLICK",item:K,input:this._input});
};
B.mousedown_list=function(K){this.dont_release=true;
};
B.mouseup_list=function(K){if(this._input){F(this._input).unbind("focus",this.delegate("focus"));
F(this._input).focus();
window.setTimeout(this.delegate("reset_focus",[this._input]),0);
}this.dont_release=false;
};
B.reset_focus=function(K){F(K).focus(this.delegate("focus"));
};
B.list_load=function(K){throw"You must override InputSelectControl.prototype.list_load";
};
B.list_receive=function(M,L,N){if(N.status!=="200 OK"){D.error("list_receive",N.code,N.messages,N);
return ;
}var K=[];
if("list" in N&&"listItems" in N.list){K=N.list.listItems;
}else{if("result" in N){K=N.result;
}else{if("results" in N){K=N.results;
}else{if("query" in N&&"result" in N.query){K=N.query.result;
}else{D.error("list_receive",N.code,"Unrecognized list result",N);
return ;
}}}}this.list_receive_hook(M,L,K);
this.handle({id:"LIST_RESULT",input:M,result:K});
};
B.list_receive_hook=function(M,L,K){};
B.position=function(N,K){var L=this.options(K);
var R=F(K).offset({border:true,padding:true});
var P=R.left;
var O=R.top+K.clientHeight+this.fudge;
var M=R.left+L.width;
var Q=F(window).width()+document.body.scrollLeft;
if(M>Q&&L.width>F(K).outerWidth()){P=P-(L.width-F(K).outerWidth())+4;
}F(N).css({top:O,left:P,width:L.width}).show();
};
B.list_show=function(N,M){if(!N){return ;
}if(!M){M=[];
}var P=this.options(N);
var L=this.val(N);
var R=null;
if(!F("#fbs_list").length){F(document.body).append('<div style="display:none;position:absolute" id="fbs_list" class="fbs-topshadow"><div class="fbs-bottomshadow"><ul class="fbs-ul"></ul></div></div>');
R=F("> .fbs-ul")[0];
}if(!R){R=this.get_list();
}F("#fbs_list > .fbs-bottomshadow").unbind().mousedown(this.delegate("mousedown_list")).mouseup(this.delegate("mouseup_list")).scroll(this.delegate("mousedown_list"));
F("li",R).each(function(){F(this).unbind();
this.fb_data=null;
});
F(R).empty();
var Q=this.filter;
if(typeof P.filter=="function"){Q=P.filter;
}if(!M.length){F(R).append(this.create_list_item({id:"NO_MATCHES",text:"no matches"},null,P).addClass("fbs-li-nomatch"));
}var O=[];
if(this.should_filter){F.each(M,function(S,T){if(Q.apply(null,[T,L])){O.push(T);
}});
O=this.filter_hook(O,M);
}else{O=M;
}var K=this;
F.each(O,function(S,T){F(R).append(K.create_list_item(T,L,P,S));
});
this.list_show_hook(R,N,P);
this.position(F("#fbs_list"),N);
};
B.list_show_hook=function(M,K,L){};
B.filter_hook=function(L,K){return L;
};
B.list_hide=function(){F("#fbs_list").hide();
this.list_hide_hook();
};
B.list_hide_hook=function(){};
B.create_list_item=function(R,M,O,N){var L=F("<li class='fbs-li'></li>")[0];
var Q=this.transform;
if(typeof O.transform=="function"){Q=O.transform;
}var P=Q.apply(this,[R,M]);
F(L).append(P);
R.index=N;
if("text" in R){R.name=R.text;
}L.fb_data=R;
var K=this;
return F(L).mouseover(function(S){K.list_select(null,this,O);
}).click(function(S){K.click_listitem(this);
});
};
B.filter=function(L,K){return true;
};
B.transform=function(L,K){return L;
};
B.loading_show=function(K){this.list_hide();
if(!F("#fbs_loading").length){F(document.body).append('<div style="display:none;position:absolute" id="fbs_loading" class="fbs-topshadow"><div class="fbs-bottomshadow"><ul class="fbs-ul"><li class="fbs-li"><div class="fbs-li-name">loading...</div></li></ul></div></div>');
}this.position(F("#fbs_loading"),K);
};
B.loading_hide=function(){F("#fbs_loading").hide();
};
B.list_select=function(N,K,M){var L=null;
this.get_list_items().each(function(O,P){if(O==N||K==P){F(P).addClass("fbs-li-selected");
L=P;
}else{F(P).removeClass("fbs-li-selected");
}});
this.list_select_hook(L,M);
return L;
};
B.list_select_hook=function(K,L){};
B.list_length=function(){return this.get_list_items().length;
};
B.list_selection=function(K){if(!K){K={};
}K.index=-1;
K.item=null;
this.get_list_items().each(function(L,M){if(M.className.indexOf("fbs-li-selected")!=-1){K.index=L;
K.item=M;
return false;
}});
return K;
};
B.list_select_next=function(N,P){var L=this.list_length();
var Q=this.list_selection();
var M=Q.index+1;
if(M>=0&&M<L){var O=this.list_select(M,null,N);
var K=F(".fbs-li-name",O).text();
F(P.input).val(K);
return O;
}else{if(N.soft){F(P.input).val(this.input_text);
return this.list_select(null,null,N);
}else{if(L>0){return this.list_select(0,null,N);
}}}return null;
};
B.list_select_prev=function(N,P){var L=this.list_length();
var Q=this.list_selection();
var M=Q.index-1;
if(M>=0&&M<L){var O=this.list_select(M,null,N);
var K=F(".fbs-li-name",O).text();
F(P.input).val(K);
return O;
}else{if(N.soft){if(M<-1&&L>0){return this.list_select(L-1,null,N);
}else{F(P.input).val(this.input_text);
return this.list_select(null,null,N);
}}else{if(L>0){return this.list_select(L-1,null,N);
}}}return null;
};
B.scroll_into_view=function(M,N){if(!M){return ;
}if(!N){N=M.parentNode;
}if(!N){M.scrollIntoView(false);
return ;
}if(M.offsetTop<N.scrollTop){N.scrollTop=M.offsetTop;
return ;
}var L=F(M).height();
var K=F(N).height();
if((M.offsetTop+L)>(N.scrollTop+K)){N.scrollTop=M.offsetTop+L-K;
}};
B.em_text=function(N,M){var L=N;
var K=N.toLowerCase().indexOf(M.toLowerCase());
if(K>=0){L=N.substring(0,K)+'<em class="fbs-em">'+N.substring(K,K+M.length)+"</em>"+N.substring(K+M.length);
}return L;
};
B.caret_last=function(M){var K=this.val(M).length;
if(M.createTextRange){var L=M.createTextRange();
L.collapse(true);
L.moveEnd("character",K);
L.moveStart("character",K);
L.select();
}else{if(M.setSelectionRange){M.setSelectionRange(K,K);
}}};
function J(K){D.state.call(this);
this.c=K;
}J.prototype=new D.state();
J.prototype.constructor=J;
function H(K){J.call(this,K);
}H.prototype=new J();
H.prototype.constructor=H;
H.prototype.handle=function(M){if(!M||!M.input){return ;
}var L=this.c.options(M.input);
switch(M.id){case"TEXTCHANGE":case"DOWNARROW":var K=this.c.val(M.input);
if(K.length>=this.c.min_len){this.sm.transition("getting",null,M);
}else{this.c.list_hide();
}break;
case"DROPDOWN":this.sm.transition("getting",null,M);
break;
case"ENTERKEY":F(M.input).trigger("fb-noselect",[M]);
this.sm.transition("start");
window.clearTimeout(this.c.textchange_timeout);
break;
case"ENTERKEY-SHIFT":M.domEvent.preventDefault();
break;
default:break;
}};
function A(K){J.call(this,K);
}A.prototype=new J();
A.prototype.constructor=A;
A.prototype.enter=function(K){window.clearTimeout(this.c.loadmsg_timeout);
if(!K||!K.input){return ;
}this.c.loadmsg_timeout=window.setTimeout(this.c.delegate("loading_show",[K.input]),this.c.loadmsg_delay);
this.c.list_load(K.input);
};
A.prototype.exit=function(K){window.clearTimeout(this.c.loadmsg_timeout);
this.c.loading_hide();
};
A.prototype.handle=function(L){if(!L||!L.input){return ;
}var K=this.c.options(L.input);
switch(L.id){case"TEXTCHANGE":this.sm.transition("start",null,null,L);
break;
case"LIST_RESULT":this.sm.transition("selecting",null,L);
break;
case"ENTERKEY":F(L.input).trigger("fb-noselect",[L]);
this.c.list_hide();
this.sm.transition("start");
window.clearTimeout(this.c.textchange_timeout);
break;
case"ENTERKEY-SHIFT":L.domEvent.preventDefault();
break;
case"ESCAPEKEY":this.c.list_hide();
this.sm.transition("start");
break;
default:break;
}};
function E(K){J.call(this,K);
}E.prototype=new J();
E.prototype.constructor=E;
E.prototype.enter=function(L){if(!L||!L.input||!L.result){return ;
}this.c.list_show(L.input,L.result);
var K=this.c.options(L.input);
if(!K.soft){this.c.list_select(0,null,K);
}};
E.prototype.exit=function(K){this.c.list_select(null);
};
E.prototype.handle=function(N){if(!N||!N.input){return ;
}var L=this.c.options(N.input);
switch(N.id){case"TEXTCHANGE":this.c.should_filter=true;
this.sm.transition("start",null,null,N);
break;
case"DOWNARROW":F("#fbs_list").show();
var K=this.c.list_select_next(L,N);
this.c.scroll_into_view(K);
break;
case"UPARROW":F("#fbs_list").show();
var K=this.c.list_select_prev(L,N);
this.c.scroll_into_view(K);
break;
case"DROPDOWN":if(this.c.val(N.input)==""){this.sm.transition("start");
this.c.list_hide();
}else{this.sm.transition("getting",null,N);
this.c.should_filter=!this.c.should_filter;
}break;
case"TAB":var M=this.c.list_selection();
if(M.index==-1||!M.item){F(N.input).trigger("fb-noselect",[N]);
return ;
}this.listitem_select(N.input,M.item);
break;
case"ENTERKEY-SHIFT":this.c.create_new(N.input);
N.domEvent.preventDefault();
break;
case"ENTERKEY":var M=this.c.list_selection();
if(M.index==-1||!M.item){F(N.input).trigger("fb-noselect",[N]);
return ;
}if(F("#fbs_list").css("display")!="none"){N.domEvent.preventDefault();
}else{F(N.input).trigger("fb-submit",[M.item.fb_data]);
return ;
}this.listitem_select(N.input,M.item);
break;
case"LISTITEM_CLICK":this.listitem_select(N.input,N.item);
break;
case"ESCAPEKEY":this.c.list_hide();
this.sm.transition("start");
break;
default:break;
}};
E.prototype.listitem_select=function(L,M){if(!M){return ;
}switch(M.fb_data.id){case"NO_MATCHES":break;
default:var K=F(".fbs-li-name",M).text();
F(L).val(K);
this.c.caret_last(L);
F(L).trigger("fb-select",[M.fb_data]).trigger("suggest",[M.fb_data]);
this.c.list_hide();
break;
}};
function G(M){if(!M.service_url){return false;
}var K=window.location.pathname.length;
var L=window.location.href;
var L=L.substr(0,L.length-K);
if(L==M.service_url){return false;
}return true;
}F.fn.freebaseSuggest=function(L,K){if((typeof L=="undefined"||typeof L=="object")&&K==null){K=L;
L="activate";
}if(L=="activate"){F(this)._freebaseInput(D.suggest.getInstance(),K);
}else{if(L=="destroy"){D.suggest.getInstance().destroy(this);
}}return F(this);
};
function C(){D.InputSelectControl.call(this);
this.default_options={width:275,soft:true,suggest_new:null,flyout:true,service_url:"http://www.freebase.com",ac_path:"/api/service/search",ac_param:{type:"/common/topic",start:0,limit:20},ac_qstr:"prefix",blurb_path:"/api/trans/blurb",blurb_param:{maxlength:300},thumbnail_path:"/api/trans/image_thumb",thumbnail_param:{maxwidth:70,maxheight:70},filter:null,transform:null,initialize:false};
}C.prototype=new D.InputSelectControl();
C.prototype.constructor=C;
C.instance=null;
C.getInstance=function(){if(!C.instance){C.instance=new C();
}return C.instance;
};
var B=C.prototype;
B.list_load=function(L){if(!L){return ;
}if(!"fb_id" in L){return ;
}var K=this.val(L);
if(!K.length){return ;
}if(!this.cache[L.fb_id]){this.cache[L.fb_id]={};
}if(K in this.cache[L.fb_id]){window.clearTimeout(this.handle_timeout);
this.handle_timeout=window.setTimeout(this.delegate("handle",[{id:"LIST_RESULT",input:L,result:this.cache[L.fb_id][K]}]),0);
return ;
}var M=this.options(L);
var K=this.val(L);
var N=M.ac_param;
N[M.ac_qstr]=K;
F.ajax({type:"GET",url:M.service_url+M.ac_path,data:N,success:this.delegate("list_receive",[L,K]),dataType:G(M)?"jsonp":"json",cache:true});
};
B.list_receive_hook=function(M,L,K){if(!this.cache[M.fb_id]){this.cache[M.fb_id]={};
}this.cache[M.fb_id][L]=K;
};
B.list_show_hook=function(P,N,O){if(!F(P).next(".fbs-selectnew").length){F(P).after('<div style="display: none;" class="fbs-selectnew"></div>');
}var M=F(P).next(".fbs-selectnew");
if(O.suggest_new){var L=this;
F(M).unbind().empty().append('<div class="fbs-selectnew-description">Your item not in the list?</div><button type="submit" class="fbs-selectnew-button"></button><span class="fbs-selectnew-shortcut">(Shift+Enter)</span>').mouseover(function(Q){L.list_select(null);
L.flyout_hide();
});
var K=M.find(".fbs-selectnew-button").eq(0);
F(K).unbind().empty().append(O.suggest_new).click(function(Q){L.create_new(N);
});
M.show();
}else{F(M).unbind().hide();
}};
B.list_hide_hook=function(){this.flyout_hide();
};
B.list_select_hook=function(K,L){this.flyout_hide();
if(K&&L&&L.flyout&&K.fb_data&&K.fb_data.id!="NO_MATCHES"){this.flyout(K,L);
}};
B.create_new=function(K){F(K).trigger("fb-select-new",[{name:this.val(K)}]).trigger("suggest-new",[{name:this.val(K)}]);
this.list_hide();
this.transition("start");
};
B.transform=function(N,O){var L=this;
var P=[];
if(N.type){F.each(N.type,function(T,U){if(U.id!="/common/topic"){P.push(L.name(U));
}});
}P=P.join(", ");
var S=[];
if(N.domain){F.each(N.domain,function(T,U){S.push(L.name(U));
});
}S=S.join(", ");
var M=[];
if(N.alias){F.each(N.alias,function(T,U){M.push(U);
});
}M=M.join(", ");
var Q=[];
if(N.properties){F.each(N.properties,function(T,U){Q.push(U);
});
}Q=Q.join(", ");
var K=document.createElement("div");
F(K).append('<div class="fbs-li-aliases"></div><div class="fbs-li-name"></div><div class="fbs-li-types"></div><div class="fbs-li-domains"></div><div class="fbs-li-props"></div>');
if(M.length){var R=F(".fbs-li-aliases",K).append(document.createTextNode("("+M+")")).text();
if(O){F(".fbs-li-aliases",K).empty().append(this.em_text(R,O));
}}else{F(".fbs-li-aliases",K).remove();
}var R=F(".fbs-li-name",K).append(document.createTextNode(this.name(N))).text();
if(O){F(".fbs-li-name",K).empty().append(this.em_text(R,O));
}if(P.length){F(".fbs-li-types",K).append(document.createTextNode(P));
}else{F(".fbs-li-types",K).remove();
}if(S.length){F(".fbs-li-domains",K).append(document.createTextNode(S));
}else{F(".fbs-li-domains",K).remove();
}if(Q.length){F(".fbs-li-props",K).append(document.createTextNode(Q));
}else{F(".fbs-li-props",K).remove();
}return K.innerHTML;
};
B.flyout=function(K,L){this.flyout_callback=this.flyout_resources(K,L);
};
B.flyout_resources=function(K,L){window.clearTimeout(this.flyout_resources_timeout);
this.flyout_resources_timeout=window.setTimeout(this.delegate("flyout_resources_delay",[K,L]),100);
};
B.flyout_resources_delay=function(L,N){var O=L.fb_data;
var M=["article","image"];
var K=new I(this,L,N);
return K;
};
B.flyout_hide=function(){if(this.flyout_callback){this.flyout_callback.destroy();
}F("#fbs_flyout").hide();
};
B.flyout_show=function(Q,S,N,P){if("none"==F("#fbs_list").css("display")){return ;
}var R=this.list_selection().item;
if(!(Q==R&&Q.fb_data.id==R.fb_data.id)){return ;
}if(!F("#fbs_flyout").length){F(document.body).append('<div style="display:none;position:absolute" id="fbs_flyout" class="fbs-topshadow"><div class="fbs-bottomshadow"><div class="fbs-flyout-container"><div class="fbs-flyout-name"></div><div class="fbs-flyout-image"></div><div class="fbs-flyout-types"></div><div class="fbs-flyout-domains"></div><div class="fbs-flyout-blurb"></div></div></div></div>');
}F("#fbs_flyout .fbs-flyout-name").empty().append('<a href="'+this.freebase_url(Q.fb_data.id,S)+'">'+F(".fbs-li-name",Q).text()+"</a>");
F("#fbs_flyout .fbs-flyout-image").empty();
if(N!="#"){F("#fbs_flyout .fbs-flyout-image").append('<img src="'+N+'"/>');
}F("#fbs_flyout .fbs-flyout-types").empty().append(F(".fbs-li-types",Q).text());
F("#fbs_flyout .fbs-flyout-domains").empty().append(F(".fbs-li-domains",Q).text());
F("#fbs_flyout .fbs-flyout-blurb").empty().append(P);
var O=F(this.get_list()).offset();
var K=O.left+S.width;
var L=document.body.scrollLeft;
var M=F(window).width();
if((K+S.width)>(L+M)){K=O.left-S.width;
}F("#fbs_flyout").css({top:O.top,left:K,width:S.width}).show();
};
B.freebase_url=function(M,L){var K=L.service_url+"/view"+D.quote_id(M);
return K;
};
B.release_hook=function(K){F(this.get_list()).next(".fbs-selectnew").remove();
D.InputSelectControl.prototype.release_hook.call(this,K);
};
function I(L,K,M){this.owner=L;
this.li=K;
this.options=M;
var N=this;
F.each(["article","image"],function(O,Q){var P=K.fb_data[Q];
if(P&&typeof P=="object"){P=P.id;
}N["load_"+Q](P);
});
}I.prototype={load_article:function(K){if(K){F.ajax({type:"GET",url:this.blurb_url(K),data:this.options.blurb_param,success:D.delegate(this.receive_article,this),error:D.delegate(this.receive_article_error,this),dataType:G(this.options)?"jsonp":null,cache:true});
}else{this.receive("article","&nbsp;");
}},receive_article:function(K){if(typeof K=="object"){if(K.status!=="200 OK"){D.error("SuggestControl.blurb_receive",K.code,K.messages,K);
return ;
}K=K.result.body;
}this.receive("article",K);
},receive_article_error:function(){this.receive("article","Description could not be displayed");
},load_image:function(M){if(M){var K=new Image();
var L=this.thumbnail_url(M);
K.onload=D.delegate(this.receive_image,this,[L,K]);
K.onerror=D.delegate(this.receive_image,this,["#",K]);
K.src=L;
}else{this.receive("image","#");
}},receive_image:function(L,K){this.receive("image",L);
K.onload=K.onerror=null;
},blurb_url:function(K){return this.options.service_url+this.options.blurb_path+D.quote_id(K);
},thumbnail_url:function(M){var L=this.options.service_url+this.options.thumbnail_path+D.quote_id(M);
var K=F.param(this.options.thumbnail_param);
if(K){L+="?"+K;
}return L;
},receive:function(L,K){if(!this.owner){return ;
}this[L]={data:K};
if(this.image&&this.article){this.owner.flyout_show(this.li,this.options,this.image.data,this.article.data);
}},destroy:function(){this.owner=this.li=this.options=this.image=this.article=null;
}};
D.suggest=C;
})(jQuery,window.freebase.controls);


/* parallax-search-widget.js */
(function(){var B=window.MetawebSuite;
if(!("widgets" in B.ui)){B.ui.widgets={};
}var A=B.ui.widgets.ParallaxSearchWidget=function(C){this._queryHandler=C;
this._input=null;
this._previousSearch="";
this._timerID=null;
this._selectedLink=null;
this._popupDismiss=null;
var D=this;
this._inputOnKeyUp=function(E){var F=D._input.value;
if(F!=D._previousSearch){D._previousSearch=F;
if(D._timerID!=null){window.clearTimeout(D._timerID);
D._timerID=null;
}D._dismissPopup();
D._clearResults();
if(F.length>=3){D._scheduleQueryProcess(F);
}}};
this._inputOnKeyDown=function(E){if(E.keyCode==38){D._selectPreviousResult();
}else{if(E.keyCode==40){D._selectNextResult();
}else{if(E.keyCode==13){D._invokeCurrentExploreLink(E);
}else{if(E.keyCode==27){D.hide();
}else{return true;
}}}}return B.ui.cancelEvent(E);
};
this._onClickShowMoreGeneralResults=function(E){return D._showMoreGeneralResults(E);
};
this._onClickShowMoreSpecificResults=function(E){return D._showMoreSpecificResults(E);
};
this._constructPanels();
};
A.defaultQueryHandler=function(C){var D=[];
if("id" in C){D.push("id="+encodeURIComponent(C.id));
D.push("label="+encodeURIComponent(C.label));
}else{D.push("type="+encodeURIComponent(C.typeID));
}if("search" in C){D.push("search="+encodeURIComponent(C.search));
}window.location="browse.html?"+D.join("&");
};
A.prototype.dispose=function(){this.uninstallUI();
this._dismissPopup();
this._disposePanels();
};
A.prototype.focus=function(){if(this._input!=null){this._input.focus();
}return this;
};
A.prototype.hide=function(){this._dismissPopup();
};
A.prototype.installUI=function(C){this._input=C;
myJQuery(this._input).keyup(this._inputOnKeyUp);
myJQuery(this._input).keydown(this._inputOnKeyDown);
return this;
};
A.prototype.uninstallUI=function(){if(this._input!=null){this._dismissPopup();
myJQuery(this._input).unbind("keyup",this._inputOnKeyUp);
myJQuery(this._input).unbind("keydown",this._inputOnKeyDown);
this._input=null;
}return this;
};
A.prototype.query=function(C){this._input.value=C;
this._previousSearch=C;
this._input.focus();
this._clearResults();
this._showStatusPanel();
this._startQueryProcess(C);
};
A._resultPanelHtml='<div class="metawebSuite-parallaxSearchWidget-result-section" style="border-top: none;"><div class="metawebSuite-parallaxSearchWidget-result-list"></div><div class="metawebSuite-parallaxSearchWidget-result-show-more"><a href="javascript:{}" class="action">more collections about <span class="metawebSuite-parallaxSearchWidget-result-highlight">blah</span></a></a></div></div><div class="metawebSuite-parallaxSearchWidget-result-section"><div class="metawebSuite-parallaxSearchWidget-result-status">Trying to find more specific topics...</div><div class="metawebSuite-parallaxSearchWidget-result-heading">Topics mentioning <span class="metawebSuite-parallaxSearchWidget-result-highlight">blah</span> in their text content</div><div class="metawebSuite-parallaxSearchWidget-result-list"></div><div class="metawebSuite-parallaxSearchWidget-result-show-more"><a href="javascript:{}" class="action">more topics mentioning <span class="metawebSuite-parallaxSearchWidget-result-highlight">blah</span></a></div></div><div class="metawebSuite-parallaxSearchWidget-result-section"><div class="metawebSuite-parallaxSearchWidget-result-status">Trying to find more individual topics...</div><div class="metawebSuite-parallaxSearchWidget-result-heading">Individual topics most resembling <span class="metawebSuite-parallaxSearchWidget-result-highlight">blah</span></div><div class="metawebSuite-parallaxSearchWidget-result-list"></div></div>';
A._statusPanelHtml='<div class="metawebSuite-parallaxSearchWidget-status-message">Working...</div>';
A._errorPanelHtml='<div class="metawebSuite-parallaxSearchWidget-error-title">Oops! Our web server is on strike...</div><div class="metawebSuite-parallaxSearchWidget-error-message"></div>';
A.prototype._constructPanels=function(){var E=B.ui.createHTMLElement("div");
E.className="metawebSuite-parallaxSearchWidget-result-panel";
E.innerHTML=A._resultPanelHtml;
this._resultPanelDom={panel:E};
this._resultPanelDom.generalResultSection=E.childNodes[0];
this._resultPanelDom.generalResultList=this._resultPanelDom.generalResultSection.childNodes[0];
this._resultPanelDom.generalResultShowMore=this._resultPanelDom.generalResultSection.childNodes[1];
this._resultPanelDom.generalResultQueryText=this._resultPanelDom.generalResultShowMore.firstChild.getElementsByTagName("span")[0];
this._resultPanelDom.specificResultSection=E.childNodes[1];
this._resultPanelDom.specificResultStatus=this._resultPanelDom.specificResultSection.childNodes[0];
this._resultPanelDom.specificResultHeading=this._resultPanelDom.specificResultSection.childNodes[1];
this._resultPanelDom.specificResultList=this._resultPanelDom.specificResultSection.childNodes[2];
this._resultPanelDom.specificResultShowMore=this._resultPanelDom.specificResultSection.childNodes[3];
this._resultPanelDom.specificResultQueryText1=this._resultPanelDom.specificResultHeading.getElementsByTagName("span")[0];
this._resultPanelDom.specificResultQueryText2=this._resultPanelDom.specificResultShowMore.firstChild.getElementsByTagName("span")[0];
this._resultPanelDom.individualResultSection=E.childNodes[2];
this._resultPanelDom.individualResultStatus=this._resultPanelDom.individualResultSection.childNodes[0];
this._resultPanelDom.individualResultHeading=this._resultPanelDom.individualResultSection.childNodes[1];
this._resultPanelDom.individualResultList=this._resultPanelDom.individualResultSection.childNodes[2];
this._resultPanelDom.individualResultQueryText=this._resultPanelDom.individualResultHeading.getElementsByTagName("span")[0];
var D=B.ui.createHTMLElement("div");
D.className="metawebSuite-parallaxSearchWidget-status-panel";
D.innerHTML=A._statusPanelHtml;
this._statusPanelDom={panel:D};
var C=B.ui.createHTMLElement("div");
C.className="metawebSuite-parallaxSearchWidget-error-panel";
C.innerHTML=A._errorPanelHtml;
this._errorPanelDom={panel:C};
this._errorPanelDom.message=C.childNodes[1];
};
A.prototype._disposePanels=function(){this._statusPanelDom=null;
this._resultPanelDom=null;
this._errorPanelDom=null;
};
A.prototype._dismissPopup=function(){if(this._popupDismiss!=null){this._popupDismiss();
this._popupDismiss=null;
}};
A.prototype._scheduleQueryProcess=function(D){this._showStatusPanel();
var C=this;
window.setTimeout(function(){C._startQueryProcess(D);
},300);
};
A.prototype._showStatusPanel=function(){this._dismissPopup();
this._positionFloatingPanel(this._statusPanelDom.panel);
var C=this;
var D=B.ui.layers.pushEphemeralLayer(function(){B.ui.removeFromDom(C._statusPanelDom.panel);
},[C._statusPanelDom.panel]);
this._popupDismiss=function(){B.ui.layers.popLayer(D);
};
};
A.prototype._showErrorPanel=function(E){this._dismissPopup();
this._errorPanelDom.message.innerHTML=E;
this._positionFloatingPanel(this._errorPanelDom.panel);
var C=this;
var D=B.ui.layers.pushEphemeralLayer(function(){B.ui.removeFromDom(C._errorPanelDom.panel);
},[C._errorPanelDom.panel]);
this._popupDismiss=function(){B.ui.layers.popLayer(D);
};
};
A.prototype._showResultPanel=function(){this._dismissPopup();
this._positionFloatingPanel(this._resultPanelDom.panel);
myJQuery(this._resultPanelDom.generalResultShowMore.firstChild).click(this._onClickShowMoreGeneralResults);
myJQuery(this._resultPanelDom.specificResultShowMore.firstChild).click(this._onClickShowMoreSpecificResults);
var C=this;
var D=B.ui.layers.pushEphemeralLayer(function(){myJQuery(C._resultPanelDom.generalResultShowMore.firstChild).unbind("click",C._onClickShowMoreGeneralResults);
myJQuery(C._resultPanelDom.specificResultShowMore.firstChild).unbind("click",C._onClickShowMoreSpecificResults);
B.ui.removeFromDom(C._resultPanelDom.panel);
},[C._resultPanelDom.panel]);
this._popupDismiss=function(){B.ui.layers.popLayer(D);
};
};
A.prototype._positionFloatingPanel=function(D){D.style.display="block";
B.ui.addToDom(D);
var C=document.body.scrollWidth;
var F=D.offsetWidth;
var E=myJQuery(this._input).offset();
if(E.left+F>C){D.style.left=(E.left+this._input.offsetWidth-F)+"px";
}else{D.style.left=E.left+"px";
}D.style.top=(E.top-1+this._input.offsetHeight)+"px";
};
A.prototype._clearResults=function(){this._selectLink();
this._resultPanelDom.generalResultList.innerHTML="";
this._resultPanelDom.specificResultSection.style.display="block";
this._resultPanelDom.specificResultStatus.style.display="block";
this._resultPanelDom.specificResultList.innerHTML="";
this._resultPanelDom.specificResultHeading.style.display="none";
this._resultPanelDom.specificResultShowMore.style.display="none";
this._resultPanelDom.individualResultList.innerHTML="";
this._resultPanelDom.individualResultSection.style.display="none";
};
A.prototype._makeErrorHandler=function(){var C=this;
return function(D){C._showErrorPanel(D);
};
};
A.prototype._startQueryProcess=function(E){try{this._resultPanelDom.generalResultQueryText.innerHTML=E;
this._resultPanelDom.specificResultQueryText1.innerHTML=E;
this._resultPanelDom.specificResultQueryText2.innerHTML=E;
this._resultPanelDom.individualResultQueryText.innerHTML=E;
var C=this;
B.freebase.mql.read([{"id":null,"name":null,"name~=":"*"+E+"*","type":"/type/type","/freebase/type_profile/instance_count":null}],function(F){C._onQueryTypeDone(E,F);
},this._makeErrorHandler());
}catch(D){log(D);
}};
A.prototype._onQueryTypeDone=function(K,D){try{if(K!=this._previousSearch){return ;
}var E=D.result;
for(var F=E.length-1;
F>=0;
F--){var J=E[F];
if(J["/freebase/type_profile/instance_count"]==null){E.splice(F,1);
}else{J.fromUser=J.id.indexOf("/user/")==0?1:0;
J.lName=J.name.toLowerCase();
var C=J.lName.indexOf(K);
if(C==0){J.distance=0;
}else{if(C>0){var N=J.lName.substr(0,C);
var O=N.lastIndexOf(" ")+1;
J.distance=N.length-O;
}else{J.distance=Number.POSITIVE_INFINITY;
}}}}E.sort(function(Q,P){var T=Q.lName;
var R=P.lName;
var S=Q.fromUser-P.fromUser;
if(S==0){S=Q.distance-P.distance;
if(S==0){S=T.length-R.length;
if(S==0){S=P["/freebase/type_profile/instance_count"]-Q["/freebase/type_profile/instance_count"];
if(S==0){S=Q.id.localeCompare(P.id);
}}}}return S;
});
var H=this._resultPanelDom.generalResultList;
H.innerHTML="";
var L=this;
var M=function(S,Q){var T=S.lName.indexOf(K);
var R=(T>=0?(S.name.substr(0,T)+"<span class='metawebSuite-parallaxSearchWidget-result-highlight'>"+S.name.substr(T,K.length)+"</span>"+S.name.substr(T+K.length)):S.name)+" collection ("+S["/freebase/type_profile/instance_count"]+" topics)";
var P=L._makeLink(R,S.id,(S.fromUser==1),Q);
P.onclick=function(){L._queryHandler({typeID:S.id});
};
H.appendChild(P);
return P;
};
for(var F=0;
F<E.length;
F++){var I=M(E[F],F<5);
if(F==0){I.className+=" metawebSuite-parallaxSearchWidget-result-row-selected";
this._selectedLink=I;
}}this._resultPanelDom.generalResultShowMore.style.display=E.length>5?"block":"none";
this._showResultPanel(true);
this._querySpecificTopics(K);
}catch(G){log(G);
}};
A.prototype._showMoreGeneralResults=function(E){var D=this._resultPanelDom.generalResultList;
var F=D.childNodes;
for(var C=0;
C<F.length;
C++){F[C].style.display="block";
}this._resultPanelDom.generalResultShowMore.style.display="none";
return B.ui.cancelEvent(E);
};
A.prototype._querySpecificTopics=function(D){var C=this;
B.freebase.mql.read([{"/type/type/instance":[{"name~=":D+"*","return":"count"}],"id":null,"name":null,"type":"/type/type"}],function(E){C._onQuerySpecificTopicsDone(D,E);
},function(E){C._onQuerySpecificTopicsFailed(D);
});
};
A.prototype._onQuerySpecificTopicsDone=function(I,D){if(I!=this._previousSearch){return ;
}var E=D.result;
for(var F=E.length-1;
F>=0;
F--){var H=E[F];
if(H.id.indexOf("/common/")==0||H.id.indexOf("/type/")==0){E.splice(F,1);
}else{H.fromUser=H.id.indexOf("/user/")==0?1:0;
H.count=H["/type/type/instance"][0];
}}E.sort(function(M,L){var N=M.fromUser-L.fromUser;
if(N==0){N=L.count-M.count;
if(N==0){N=M.name.localeCompare(L.name);
if(N==0){N=M.id.localeCompare(L.id);
}}}return N;
});
var C=this._resultPanelDom.specificResultList;
C.innerHTML="";
var J=this;
var K=function(N,M){var L=J._makeLink("... in "+N.name+" collection ("+N.count+")",N.id,(N.fromUser==1),M);
L.onclick=function(){J._queryHandler({typeID:N.id,search:I});
};
C.appendChild(L);
return L;
};
for(var F=0;
F<E.length;
F++){var G=K(E[F],F<5);
if(this._selectedLink==null&&F==0){G.className+=" metawebSuite-parallaxSearchWidget-result-row-selected";
this._selectedLink=G;
}}this._resultPanelDom.specificResultStatus.style.display="none";
this._resultPanelDom.specificResultHeading.style.display="block";
this._resultPanelDom.specificResultSection.style.display="block";
this._resultPanelDom.specificResultShowMore.style.display=E.length>5?"block":"none";
this._queryIndividualTopics(I);
};
A.prototype._showMoreSpecificResults=function(D){var E=this._resultPanelDom.specificResultList;
var F=E.childNodes;
for(var C=0;
C<F.length;
C++){F[C].style.display="block";
}this._resultPanelDom.specificResultShowMore.style.display="none";
return B.ui.cancelEvent(D);
};
A.prototype._onQuerySpecificTopicsFailed=function(C){this._resultPanelDom.specificResultSection.style.display="none";
this._queryIndividualTopics(C);
};
A.prototype._queryIndividualTopics=function(E){var D="http://www.freebase.com/api/service/search?strict=false&explain=false&limit=3&query="+encodeURIComponent(E);
var C=this;
this._resultPanelDom.individualResultSection.style.display="block";
this._resultPanelDom.individualResultList.innerHTML="";
B.freebase.mql.getJsonpQueue().call(D,function(F){C._onQueryIndividualTopicsDone(E,F);
},function(){C._onQueryIndividualTopicsFailed(E);
});
};
A.prototype._onQueryIndividualTopicsDone=function(J,I){if(J!=this._previousSearch){return ;
}this._resultPanelDom.individualResultStatus.style.display="none";
this._resultPanelDom.individualResultHeading.style.display="block";
this._resultPanelDom.individualResultList.style.display="block";
var E=this;
var G=this._resultPanelDom.individualResultList;
var H=function(V){var U=B.ui.createHTMLElement("a");
U.className="metawebSuite-parallaxSearchWidget-result-row";
U.innerHTML='<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"></tr></table>';
U.onmouseover=function(X){return E._onMouseOverLink(this,X);
};
U.onclick=function(){E._queryHandler({id:V.id,label:V.name});
};
U.href="javascript:{}";
U.style.display="block";
var W=U.firstChild;
var L=W.rows[0].insertCell(0);
var O=B.ui.createHTMLElement("div");
O.className="metawebSuite-parallaxSearchWidget-result-topic-name";
O.innerHTML=V.name;
L.appendChild(O);
var T=[];
for(var N=0;
N<V.type.length&&T.length<3;
N++){var S=V.type[N];
if(S.id!="/common/topic"){T.push(S.name);
}}if(N<V.type.length){T.push("...");
}var R=B.ui.createHTMLElement("div");
R.className="metawebSuite-parallaxSearchWidget-result-topic-types";
R.innerHTML=T.join(", ");
L.appendChild(R);
try{var Q=V.image.id;
if(typeof Q=="string"){var K=W.rows[0].insertCell(1);
K.setAttribute("width","1");
var M=B.ui.createHTMLElement("img");
M.className="metawebSuite-parallaxSearchWidget-result-topic-image";
M.src="http://freebase.com/api/trans/image_thumb"+Q+"?"+["mode=fillcrop","maxheight=40","maxwidth=40"].join("&");
K.appendChild(M);
}}catch(P){}G.appendChild(U);
return U;
};
var C=I.result;
for(var F=0;
F<C.length;
F++){var D=H(C[F]);
if(this._selectedLink==null&&F==0){D.className+=" metawebSuite-parallaxSearchWidget-result-row-selected";
this._selectedLink=D;
}}};
A.prototype._onQueryIndividualTopicsFailed=function(C){if(C!=this._previousSearch){return ;
}this._resultPanelDom.individualResultSection.style.display="none";
};
A.prototype._makeLink=function(H,G,F,D){var E=this;
var C=B.ui.createHTMLElement("a");
if(F){C.className="metawebSuite-parallaxSearchWidget-result-user-type metawebSuite-parallaxSearchWidget-result-row";
}else{C.className="metawebSuite-parallaxSearchWidget-result-row";
}C.innerHTML=H;
C.title=G;
C.href="javascript:{}";
C.style.display=D?"block":"none";
C.onmouseover=function(I){return E._onMouseOverLink(this,I);
};
return C;
};
A.prototype._onMouseOverLink=function(C,D){this._selectLink(C);
};
A.prototype._selectLink=function(C){if(this._selectedLink!=null){this._unStyleSelectedLink(this._selectedLink);
this._selectedLink=null;
}if(C){this._styleSelectedLink(C);
this._selectedLink=C;
}};
A.prototype._unStyleSelectedLink=function(C){myJQuery(C).removeClass("metawebSuite-parallaxSearchWidget-result-row-selected");
};
A.prototype._styleSelectedLink=function(C){myJQuery(C).addClass("metawebSuite-parallaxSearchWidget-result-row-selected");
};
A.prototype._selectPreviousResult=function(){var C=this._selectedLink;
if(C!=null){if(C.previousSibling!=null){this._selectLink(C.previousSibling);
}else{var E=C.parentNode;
if(E==this._resultPanelDom.specificResultList){var F=this._resultPanelDom.generalResultList.lastChild;
while(F!=null){if(F.style.display=="block"){this._selectLink(F);
break;
}F=F.previousSibling;
}}else{if(E==this._resultPanelDom.individualResultList){var D=this._resultPanelDom.specificResultList.lastChild;
while(D!=null){if(D.style.display=="block"){this._selectLink(D);
break;
}D=D.previousSibling;
}}}}}};
A.prototype._selectNextResult=function(){var C=this._selectedLink;
if(C!=null){if(C.nextSibling!=null&&C.nextSibling.style.display=="block"){this._selectLink(C.nextSibling);
}else{var D=C.parentNode;
if(D==this._resultPanelDom.generalResultList){if(this._resultPanelDom.specificResultList.firstChild!=null){this._selectLink(this._resultPanelDom.specificResultList.firstChild);
}}else{if(D==this._resultPanelDom.specificResultList){if(this._resultPanelDom.individualResultList.firstChild!=null){this._selectLink(this._resultPanelDom.individualResultList.firstChild);
}}}}}};
A.prototype._invokeCurrentExploreLink=function(D){if(this._selectedLink!=null){if(this._selectedLink.href=="javascript:{}"){var C=this._selectedLink;
window.setTimeout(function(){C.onclick();
},100);
}else{window.location.href=this._selectedLink.href;
}}};
})();


/* terminal.js */
window.MetawebSuite.system.onFinishLoadingPackage("metaweb-suite-search-widgets");


/* schema-widgets-package.js */
(function() {
    var mw = window.MetawebSuite;
    mw.system.onStartLoadingNativePackage(
        "schema-widgets",
        [   "dimension-picker-widget.js",
            "dimension-path-picker-widget.js",
            "terminal.js"
        ],
        [   "dimension-picker-widget.css"
        ]
    );
})();


/* schema-widgets-bundle.js */


/* dimension-path-picker-widget.js */
(function(){var B=window.MetawebSuite;
if(!("widgets" in B.ui)){B.ui.widgets={};
}var A=B.ui.widgets.DimensionPathPickerWidget=function(D,C,E){this.specified=D;
this._baseQueryNode=null;
this._basePropertyPicker=null;
this._includeNativeTypes=(C);
this._useCVTsAsIs=(E);
this._segments=[];
this._elmt;
this._dom;
};
A.prototype.getExpectedType=function(){if(this._segments.length>0){return this._segments[this._segments.length-1].dimension.expectedType;
}return null;
};
A.prototype.getState=function(){var E={s:this.specified};
if(this.specified){var C=[];
for(var D=0;
D<this._segments.length;
D++){var G=this._segments[D].dimension;
var F=G.path;
C.push(compressPath(F));
}E.d=C;
}return E;
};
A.prototype.reconfigureFromState=function(D){if(typeof D!="object"){return ;
}this.specified=D.s;
this._segments=[];
if(this.specified){var G=D.d;
for(var C=0;
C<G.length;
C++){var F=decompressPath(G[C]);
var E={path:F};
this._segments.push({dimension:E});
}}};
A.prototype.getDimensions=function(){var D=[];
for(var C=0;
C<this._segments.length;
C++){D.push(this._segments[C].dimension);
}return D;
};
A.prototype.getTotalPath=function(){var D=[];
for(var C=0;
C<this._segments.length;
C++){D=D.concat(this._segments[C].dimension.path);
}return D;
};
A.prototype.dispose=function(){};
A.prototype.setBaseQueryNode=function(C){this._baseQueryNode=C;
};
A.prototype.setBasePropertyPicker=function(C){this._basePropertyPicker=C;
};
A.prototype.installUI=function(C){this._elmt=C;
this._render();
};
A.prototype.uninstallUI=function(){if(this._elmt!=null){this._elmt.innerHTML="";
this._elmt=null;
this._dom=null;
}};
A.prototype._render=function(){this._elmt.innerHTML="";
var D=this;
if(this._segments.length==0){if(this.specified){this._elmt.appendChild(document.createTextNode("use the topics themselves \u2022 or "));
var F=B.ui.createHTMLElement("span");
F.innerHTML='<a class="action" href="javascript:{}">select&nbsp;a&nbsp;property&nbsp;&raquo;</a>';
F.firstChild.onclick=function(){D._showDropdown(F,0);
};
this._elmt.appendChild(F);
}else{this._elmt.appendChild(document.createTextNode("unspecified \u2022 "));
var F=B.ui.createHTMLElement("span");
F.innerHTML='<a class="action" href="javascript:{}">select&nbsp;property&nbsp;&raquo;</a>';
F.firstChild.onclick=function(){D._showDropdown(F,0);
};
this._elmt.appendChild(F);
}}else{var C=function(H,K){var M=K.dimension.path;
var J=M[M.length-1];
var L=J.property;
var I=B.ui.createHTMLElement("span");
I.innerHTML='<a class="action" href="javascript:{}">'+L+"</a>";
I.firstChild.onclick=function(){D._showDropdown(I,H);
};
D._elmt.appendChild(I);
if("label" in K.dimension){I.firstChild.firstChild.nodeValue=K.dimension.label;
}else{SchemaUtil.tryGetPropertyLabel(L,function(N){I.firstChild.firstChild.nodeValue=N;
});
}};
var E;
for(E=0;
E<this._segments.length;
E++){var G=this._segments[E];
if(E>0){this._elmt.appendChild(document.createTextNode(" \u2192 "));
}C(E,G);
}this._elmt.appendChild(document.createTextNode(" \u2022 "));
var F=B.ui.createHTMLElement("span");
F.innerHTML='<a class="action" href="javascript:{}">chain&nbsp;another&nbsp;property&nbsp;&raquo;</a>';
F.firstChild.onclick=function(){D._showDropdown(F,E);
};
this._elmt.appendChild(F);
}};
A.prototype._showDropdown=function(F,E){var D=this;
var C=new TypeStack(this._getQueryNode(E),this._includeNativeTypes,this._useCVTsAsIs);
C.runWhenInitialized(function(){var G=C.getAllDimensions();
C.dispose();
G.sort(function(I,H){var J=I.label.localeCompare(H.label);
if(J==0){J=I.fullLabel.localeCompare(H.fullLabel);
}return J;
});
D._showDropdownGivenDimensions(F,E,G);
});
};
A.prototype._showDropdownGivenDimensions=function(F,E,H){var C=this;
var G=[];
var D=function(I){C._pickDimension(E,I);
};
if(E==0){G.push({label:"(Don't specify anything)",icon:null,onclick:function(){C._dontSpecify();
}});
G.push({label:"(Use topics themselves)",icon:null,onclick:function(){C._useTopicsThemselves();
}});
}if(E<this._segments.length){G.push({label:"(Remove property)",icon:null,onclick:function(){C._truncate(E);
}});
}B.ui.widgets.DimensionPickerWidget.show(F,H,D,G);
};
A.prototype._pickDimension=function(C,D){if(C<this._segments.length){this._segments=this._segments.slice(0,C);
}this._segments.push({dimension:D});
this.specified=true;
if(this._elmt!=null){this._render();
}};
A.prototype._dontSpecify=function(){this.specified=false;
this._segments=[];
if(this._elmt!=null){this._render();
}};
A.prototype._useTopicsThemselves=function(){this.specified=true;
this._segments=[];
if(this._elmt!=null){this._render();
}};
A.prototype._truncate=function(C){this._segments=this._segments.slice(0,C);
if(this._elmt!=null){this._render();
}};
A.prototype.getQueryNode=function(){return this._getQueryNode(this._segments.length);
};
A.prototype._getQueryNode=function(D){if(D==0){if(this._basePropertyPicker!=null){return this._basePropertyPicker.getQueryNode();
}else{return B.system.clone(this._baseQueryNode);
}}else{var C=this._getQueryNode(D-1);
var H=this._segments[D-1].dimension.path;
var I=null;
for(var E=0;
E<H.length;
E++){var G=H[E];
var F={};
F[backwardPathSegment(G)]=[C];
I=C;
C=F;
}I["return"]="count";
return C;
}};
})();


/* dimension-picker-widget.js */
(function(){var B=window.MetawebSuite;
if(!("widgets" in B.ui)){B.ui.widgets={};
}var A=B.ui.widgets.DimensionPickerWidget={};
A.show=function(G,E,R,C){var T=new B.ui.menus.PopupMenu(G);
T.bodyDiv.style.overflow="auto";
T.bodyDiv.style.height="400px";
for(var O=0;
O<C.length;
O++){var D=C[O];
T.appendMenuItem(D.label,D.icon,D.onclick);
}var M={};
var U=[];
for(var O=0;
O<E.length;
O++){var P=E[O];
var S;
if(P.expectedType in M){S=M[P.expectedType];
}else{S=M[P.expectedType]={dimensions:[],label:"To "+P.expectedTypeLabel};
U.push(S);
}S.dimensions.push(P);
}U.sort(function(W,V){return V.dimensions.length-W.dimensions.length;
});
var Q=function(W,V){var X=W.label.localeCompare(V.label);
if(X==0){X=W.fullLabel.localeCompare(V.fullLabel);
}return X;
};
var K=function(a){var e=a.getPath();
var c=e.getLastSegment();
var d=a.label;
var X=B.ui.createHTMLElement("span");
var Y=B.ui.createHTMLElement("span");
Y.title=c.propertyID;
Y.appendChild(document.createTextNode(a.label));
X.appendChild(Y);
var b=B.freebase.schemas.getContainingTypeOfProperty(c.propertyID);
if(b!=null){var Z=(typeof b.name=="string")?b.name:b.id;
var W=B.ui.createHTMLElement("span");
W.className="pivot-choice-menu-hint";
W.appendChild(document.createTextNode(" ("+Z+")"));
W.title=b.id;
X.appendChild(W);
d+=" "+Z;
}var V=T.appendMenuItem(X,null,function(){R(a);
});
V.setAttribute("searchText",d.toLowerCase());
};
for(var O=0;
O<U.length;
O++){var S=U[O];
if(S.dimensions.length<3){break;
}T.appendSection(S.label);
S.dimensions.sort(Q);
for(var N=0;
N<S.dimensions.length;
N++){K(S.dimensions[N]);
}}if(O<U.length-1){var L=[];
for(;
O<U.length;
O++){var S=U[O];
L=L.concat(S.dimensions);
}T.appendSection("To Other Types of Topic");
L.sort(Q);
for(var O=0;
O<L.length;
O++){K(L[O]);
}}var F=B.ui.createHTMLElement("div");
F.className="dimension-picker-widget-quick-filter-section";
var I=B.ui.createHTMLElement("div");
I.className="dimension-picker-widget-quick-filter-section-heading";
I.appendChild(document.createTextNode("Quick search:"));
F.appendChild(I);
var J=B.ui.createHTMLElement("div");
J.className="dimension-picker-widget-quick-filter-section-input";
J.appendChild(B.ui.createHTMLElement("input"));
F.appendChild(J);
var H=F.childNodes[1].childNodes[0];
H.onkeyup=function(){var b=String.trim(H.value).toLowerCase();
var a=T.bodyDiv.childNodes;
if(b.length==0){for(var X=0;
X<a.length;
X++){a[X].style.display="block";
}}else{var Z=null;
var V=0;
for(var X=0;
X<a.length;
X++){var W=a[X];
if(W.className=="menu-section"){if(Z!=null){Z.style.display=V>0?"block":"none";
}Z=W;
V=0;
}else{var Y=W.getAttribute("searchText");
if(Y==null||Y.length==0||Y.indexOf(b)>=0){W.style.display="block";
V++;
}else{W.style.display="none";
}}}if(Z!=null){Z.style.display=V>0?"block":"none";
}}};
T.elmt.insertBefore(F,T.bodyDiv);
T.open();
H.focus();
};
})();


/* terminal.js */
window.MetawebSuite.system.onFinishLoadingPackage("metaweb-suite-schema-widgets");


/* parallax-model-package.js */
(function() {
    mw.system.onStartLoadingNativePackage(
        "parallax-model",
        [   "collection-definition.js",
            "root-type-collection-definition.js",
            "single-topic-collection-definition.js",
            "multiple-topic-collection-definition.js",
            "pivoted-collection-definition.js",
            "collection.js",
            "terminal.js"
        ],
        [
        ]
    );
})();


/* parallax-model-bundle.js */


/* collection-definition.js */
(function(){var A=window.MetawebSuite;
if(!("parallax" in A)){A.parallax={};
}})();


/* collection.js */
(function(){var B=window.MetawebSuite;
var A=B.parallax.Collection=function(C){this._definition=C;
this._facets=[];
this._totalCount=null;
this._restrictedCount=null;
this._definition.setOwnerCollection(this);
this._listeners=new B.core.ListenerQueue();
};
A.prototype.getDefinition=function(){return this._definition;
};
A.prototype.getLabel=function(){return this._definition.getLabel();
};
A.prototype.getCountLabel=function(){if(this._totalCount!=null&&this._restrictedCount!=null){if(this._totalCount==this._restrictedCount){return this._totalCount;
}else{return this._restrictedCount+"/"+this._totalCount;
}}return null;
};
A.prototype.isSingular=function(){return this._definition.isSingular();
};
A.prototype.addListener=function(C){this._listeners.add(C);
};
A.prototype.removeListener=function(C){this._listeners.remove(C);
};
A.prototype.dispose=function(){for(var C=0;
C<this._facets.length;
C++){this._facets[C].dispose();
}this._facets=null;
this._definition.dispose();
this._definition=null;
this._listeners=null;
};
A.prototype.forEachFacet=function(D){for(var C=0;
C<this._facets.length;
C++){D(this._facets[C]);
}};
A.prototype.findFacet=function(E){var D=pathToString(E);
for(var C=0;
C<this._facets.length;
C++){var F=this._facets[C];
if(D==pathToString(F.getPath())){return F;
}}return null;
};
A.prototype.addBaseRestrictions=function(C,D){C=C||{};
this._definition.addRestrictions(C,D);
return C;
};
A.prototype.addRestrictions=function(C,E){C=C||{};
this.addBaseRestrictions(C,E);
for(var D=0;
D<this._facets.length;
D++){this._facets[D].restrict(C);
}return C;
};
A.prototype.getBaseMplNode=function(){return this._definition.getMplNode();
};
A.prototype.getMplNode=function(){var D=this.getBaseMplNode();
for(var C=0;
C<this._facets.length;
C++){var E=this._facets[C];
if(E.hasRestrictions()){D=E.getMplNode(D);
}}return D;
};
A.prototype.getAllItemCount=function(F,E){var C={"id":null,"return":"count"};
this.addBaseRestrictions(C);
var D=this;
B.freebase.mql.read([C],function(G){var H=G.result[0];
D._totalCount=H;
F(H);
},E);
};
A.prototype.getAllItems=function(F,E,D){var C={"id":null,"limit":(typeof D=="number")?D:10};
this.addBaseRestrictions(C);
B.freebase.mql.read([C],function(G){F(G.result);
},E);
};
A.prototype.getRestrictedItemCount=function(F,E){var C={"id":null,"return":"count"};
this.addRestrictions(C);
var D=this;
B.freebase.mql.read([C],function(G){var H=G.result[0];
D._restrictedCount=H;
F(H);
},E);
};
A.prototype.getRestrictedItems=function(F,E,D){var C={"id":null,"limit":(typeof D=="number")?D:10};
this.addRestrictions(C);
B.freebase.mql.read([C],function(G){F(G.result);
},E);
};
A.prototype.addFacet=function(C){this._facets.push(C);
if(C.hasRestrictions()){this._updateFacets(null);
this._listeners.fire("onItemsChanged",[]);
}else{C.update(this._getRestrictedItemsQueryNode());
}};
A.prototype.removeFacet=function(D){for(var C=0;
C<this._facets.length;
C++){if(D==this._facets[C]){this._facets.splice(C,1);
if(D.hasRestrictions()){this._updateFacets(null);
this._listeners.fire("onItemsChanged",[]);
}break;
}}};
A.prototype.onFacetUpdated=function(C){this._updateFacets(C);
this._listeners.fire("onItemsChanged",[]);
};
A.prototype.onRootItemsChanged=function(){this._listeners.fire("onRootItemsChanged",[]);
this._updateFacets(null);
this._listeners.fire("onItemsChanged",[]);
};
A.prototype._updateFacets=function(F){this._totalCount=null;
this._restrictedCount=null;
var C=0;
for(var G=0;
G<this._facets.length;
G++){if(this._facets[G].hasRestrictions()){C++;
}}for(var G=0;
G<this._facets.length;
G++){var H=this._facets[G];
if(H.hasRestrictions()){if(C<=1){H.update(this._getAllItemsQueryNode());
}else{var D=this._getAllItemsQueryNode();
for(var E=0;
E<this._facets.length;
E++){if(G!=E){this._facets[E].restrict(D);
}}H.update(D);
}}else{H.update(this._getRestrictedItemsQueryNode());
}}};
A.prototype._getRestrictedItemsQueryNode=function(){return this.addRestrictions();
};
A.prototype._getAllItemsQueryNode=function(){return this.addBaseRestrictions();
};
})();


/* multiple-topic-collection-definition.js */
(function(){var B=window.MetawebSuite;
var A=B.parallax.MultipleTopicCollectionDefinition=function(C,D){this._topicIDs=C;
this._names=D;
this._ownerCollection=null;
};
A.prototype.dispose=function(){this._ownerCollection=null;
};
A.prototype.setOwnerCollection=function(C){this._ownerCollection=C;
};
A.prototype.addRestrictions=function(C){C["id|="]=this._topicIDs;
};
A.prototype.getMplNode=function(){var E=[];
for(var C=0;
C<this._topicIDs.length;
C++){E.push(new B.freebase.PathExpression._Constant(this._topicIDs[C],"freebase-id"));
}var D=new B.freebase.PathExpression._FunctionCall("topic",[new B.freebase.PathExpression._ConstantArray(E)]);
return D;
};
A.prototype.getLabel=function(){return this._names.join(", ");
};
A.prototype.isSingular=function(){return false;
};
A.prototype.hasBaseCollection=function(){return false;
};
A.prototype.getState=function(){return{i:this._topicIDs,n:this._names};
};
})();


/* pivoted-collection-definition.js */
(function(){var B=window.MetawebSuite;
var A=B.parallax.PivotedCollectionDefinition=function(C,E,D){this._baseCollection=C;
this._ownerCollection=null;
this._path=E;
this._label=D;
this._baseCollection.addListener(this);
};
A.prototype.dispose=function(){this._baseCollection.removeListener(this);
this._baseCollection=null;
this._ownerCollection=null;
};
A.prototype.getTypeID=function(){var C=this._path.getLastSegment();
var D=C.propertyID;
if(B.freebase.schemas.hasPropertyRecord(D)){return B.freebase.schemas.getPropertyRecord(D).expectedType;
}else{return null;
}};
A.prototype.setOwnerCollection=function(C){this._ownerCollection=C;
};
A.prototype.addRestrictions=function(C,D){this._path.forEachSegmentBackward(function(F){var G={};
C[B.freebase.PropertyPath.segmentToBackwardMqlKey(F)]=[G];
C=G;
});
this._baseCollection.addRestrictions(C);
if(typeof D=="object"){for(var E in D){if(D.hasOwnProperty(E)&&!(E in C)){C[E]=D[E];
}}}};
A.prototype.getMplNode=function(){var C=this._baseCollection.getMplNode();
var D=[];
this._path.forEachSegment(function(E){D.push(new B.freebase.PathExpression._Constant((E.forward?"":"!")+E.propertyID,"freebase-id"));
});
C=new B.freebase.PathExpression._FunctionCall("pivot",[C,new B.freebase.PathExpression._ConstantArray(D)]);
return C;
};
A.prototype.onItemsChanged=function(){if(this._ownerCollection!=null){this._ownerCollection.onRootItemsChanged();
}};
A.prototype.getLabel=function(){return this._label;
};
A.prototype.isSingular=function(){return false;
};
A.prototype.hasBaseCollection=function(){return true;
};
A.prototype.getBaseNodeIterator=function(){var D=[];
this._path.forEachSegmentBackward(function(E){D.push(B.freebase.PropertyPath.segmentToBackwardMqlKey(E));
});
var C=function(F,G,J){var I=D[G];
if(I in F){var E=F[I];
if(G<D.length-1){for(var H=0;
H<E.length;
H++){C(E[H],G+1,J);
}}else{for(var H=0;
H<E.length;
H++){J(E[H]);
}}}};
return function(E,F){C(E,0,F);
};
};
A.prototype.getState=function(){return{p:B.freebase.PropertyPath.pathToJSON(this._path),l:this._label};
};
})();


/* root-type-collection-definition.js */
(function(){var B=window.MetawebSuite;
var A=B.parallax.RootTypeCollectionDefinition=function(D,C){this._typeID=D;
this._textSearch=(typeof C=="string")?C:null;
this._ownerCollection=null;
};
A.prototype.dispose=function(){this._ownerCollection=null;
};
A.prototype.getTypeID=function(){return this._typeID;
};
A.prototype.setOwnerCollection=function(C){this._ownerCollection=C;
};
A.prototype.addRestrictions=function(C){C["type"]=this._typeID;
if(this._textSearch!=null){C["name~="]=this._textSearch+"*";
}};
A.prototype.getMplNode=function(){var C=new B.freebase.PathExpression._FunctionCall("instances",[new B.freebase.PathExpression._Constant(this._typeID,"freebase-id")]);
if(this._textSearch!=null){}return C;
};
A.prototype.getLabel=function(){var C=B.freebase.schemas.getTypeRecord(this._typeID);
return(C!=null)?C.name:this._typeID;
};
A.prototype.isSingular=function(){return false;
};
A.prototype.hasBaseCollection=function(){return false;
};
A.prototype.getState=function(){var C={t:this._typeID};
if(this._textSearch!=null){C.s=this._textSearch;
}return C;
};
})();


/* single-topic-collection-definition.js */
(function(){var B=window.MetawebSuite;
var A=B.parallax.SingleTopicCollectionDefinition=function(D,C){this._id=D;
this._name=C;
this._ownerCollection=null;
};
A.prototype.dispose=function(){this._ownerCollection=null;
};
A.prototype.setOwnerCollection=function(C){this._ownerCollection=C;
};
A.prototype.addRestrictions=function(C){C["id"]=this._id;
};
A.prototype.getMplNode=function(){var C=new B.freebase.PathExpression._FunctionCall("topic",[new B.freebase.PathExpression._Constant(this._id,"freebase-id")]);
return C;
};
A.prototype.getLabel=function(){return this._name;
};
A.prototype.isSingular=function(){return true;
};
A.prototype.hasBaseCollection=function(){return false;
};
A.prototype.getTopicID=function(){return this._id;
};
A.prototype.getState=function(){return{i:this._id,n:this._name};
};
})();


/* terminal.js */
window.MetawebSuite.system.onFinishLoadingPackage("metaweb-suite-parallax-model");


/* topic-renderings-package.js */
(function() {
    mw.system.onStartLoadingNativePackage(
        "topic-renderings",
        [   "topic-page-rendering.js",
            "topic-thumbnail-rendering.js",
            "terminal.js"
        ],
        [   "topic-page-rendering.css",
            "topic-thumbnail-rendering.css"
        ]
    );
})();


/* topic-renderings-bundle.js */


/* topic-page-rendering.js */
(function(){var G=window.MetawebSuite;
if(!("renderings" in G.ui)){G.ui.renderings={};
}var B=G.ui.renderings.TopicPageRendering=function(I,H){this._itemID=I;
this._callbacks=H;
};
B.prototype.installUI=function(J){this._outerDiv=J;
var H=this;
var I="http://hotshot.jdouglas.user.dev."+G.freebase.appsDomain+"/acre/json?id="+encodeURIComponent(this._itemID);
G.freebase.mql.getJsonpQueue().call(I,function(K){H._render(J,K);
},function(K){});
};
B.prototype._render=function(c,q){if(c!=this._outerDiv){return ;
}var Q=this;
var h=this._itemID;
c.innerHTML="<h1>"+q.name+' <a class="topic-view-freebase-link" href="'+G.freebase.location+"view"+h+'">view on Freebase</a></h1><table cellspacing="0" cellpadding="0"><tr valign="top"><td></td><td width="30%"></td></tr></table>';
var AB=c.childNodes[1].rows[0].cells[0];
var M=c.childNodes[1].rows[0].cells[1];
var Y=G.ui.createHTMLElement("div");
Y.className="topic-view-article-and-images-section";
Y.innerHTML='<table cellspacing="0" cellpadding="0"><tr valign="top"><td></td><td rowspan="2"></td></tr><tr><td></td></tr></table>';
M.appendChild(Y);
var L=function(d,i){return d.length>0?d[0].value:i;
};
var U=function(AI){for(var AG=0;
AG<AI.properties.length;
AG++){var o=AI.properties[AG];
var AL=o.data;
if(AL.length==0){continue;
}switch(o.id){case"/common/topic/alias":var i=G.ui.createHTMLElement("div");
i.className="topic-view-alias-section";
i.innerHTML='<span class="topic-view-section-inline-label">'+o.name+":</span> ";
c.insertBefore(i,c.childNodes[1]);
for(var AN=0;
AN<AL.length;
AN++){if(AN>0){i.appendChild(document.createTextNode(", "));
}var AJ=G.ui.createHTMLElement("span");
AJ.innerHTML=AL[AN].value;
i.appendChild(AJ);
}i.style.display="block";
break;
case"/common/topic/article":var AC=Y.firstChild.rows[0].cells[0];
var AE=AL[0].value;
if(AE.length>500){AE=AE.substr(0,500);
var AM=AE.lastIndexOf(" ");
if(AM>0){AE=AE.substr(0,AM);
}AE+=" ...";
}var AD=G.ui.createHTMLElement("div");
AD.appendChild(document.createTextNode(AE));
AC.appendChild(AD);
break;
case"/common/topic/image":var AC=Y.firstChild.rows[0].cells[1];
for(var AN=0;
AN<Math.min(3,AL.length);
AN++){var AK=AL[AN];
var AH=AK.id;
var AF=G.ui.createHTMLElement("div");
AF.className="topic-view-thumbnail-container";
var AP=G.ui.createHTMLElement("img");
AP.src=G.freebase.apiLocation+"trans/image_thumb"+AH+"?"+["mode=fill","maxheight=100","maxwidth=100"].join("&");
myJQuery(AP).click(function(d){return G.ui.showLightboxForImage(this,d);
});
AF.style.height="100px";
AF.style.width="100px";
AF.style.overflow="hidden";
AF.appendChild(AP);
AC.appendChild(AF);
}break;
case"/common/topic/webpage":var t=G.ui.createHTMLElement("div");
t.className="topic-view-web-links-section";
t.innerHTML='<div class="topic-view-section-label">Web Links</div>';
Y.firstChild.rows[1].cells[0].appendChild(t);
for(var AN=0;
AN<AL.length;
AN++){var AK=AL[AN];
var j=AK["/common/webpage/uri"][0].value;
var AF=G.ui.createHTMLElement("div");
var AO=G.ui.createHTMLElement("a");
AO.href=j;
AO.target="_blank";
AO.innerHTML=L(AK["/common/webpage/description"],j);
AF.appendChild(AO);
t.appendChild(AF);
}break;
}}};
var I=[];
var R=[];
var J=[];
var N=[];
var w=[];
var H=function(j){var i={typeEntry:j,propertyEntries:[]};
for(var t=0;
t<j.properties.length;
t++){var d=j.properties[t];
var o=d.data;
if(o==null||o.length==0){continue;
}if(d.unique){I.push(d);
}else{if(d.disambiguator&&d.expected_type["/freebase/type_hints/mediator"]!=true){R.push(d);
}else{if(o.length>3){J.push(d);
}else{i.propertyEntries.push(d);
}}}}if(i.propertyEntries.length>0){if(i.propertyEntries.length>3){N.push(i);
}else{w.push(i);
}}};
var T=function(d){if(d.id=="/common/topic"){U(d);
}else{H(d);
}};
for(var AA=0;
AA<q.domains.length;
AA++){var V=q.domains[AA];
for(var l=0;
l<V.types.length;
l++){var e=V.types[l];
T(e);
}}var b=function(d){return"."+d.join(".");
};
var x=function(j,i){var d=G.ui.createHTMLElement("a");
d.className="action";
d.href="javascript:{}";
d.innerHTML="&nbsp;[&nbsp;+&nbsp;]&nbsp;";
d.onclick=function(){Logging.log("topic-add-more",{path:b(j)});
F(h,j,i,d.parentNode);
};
return d;
};
var f=function(o,i,j){var d=G.ui.createHTMLElement("a");
d.className="action";
d.href="javascript:{}";
d.innerHTML="&nbsp;[&nbsp;+&nbsp;]&nbsp;";
d.onclick=function(){Logging.log("topic-add-more-cvt",{path:b(o)});
A(h,o,i,j,d.parentNode.parentNode);
};
return d;
};
var P=function(o,i){if("id" in i){var d=G.ui.createHTMLElement("a");
d.className="topic-view-focus-link";
d.href=G.freebase.location+"view"+i.id;
d.title=i.id;
$(d).click(function(t){Logging.log("topic-to-topic",{"id":i.id});
Q._callbacks.onFocus(i.id,i.name);
t.preventDefault();
});
if("/common/topic/image" in i){var j=G.ui.createHTMLElement("img");
j.className="topic-view-micro-thumbnail";
if(i["/common/topic/image"]!=null){j.src=G.freebase.apiLocation+"trans/image_thumb"+i["/common/topic/image"].id+"?"+["mode=fillcrop","maxheight=40","maxwidth=40"].join("&");
myJQuery(j).click(function(t){return G.ui.showLightboxForImage(this,t);
});
}else{j.src=G.ui.params.baseUrl+"images/blank-16x16.png";
j.style.width="38px";
j.style.height="38px";
j.style.border="1px solid #ddd";
}d.appendChild(j);
}d.appendChild(document.createTextNode(i.name));
o.appendChild(d);
}else{o.innerHTML=i.value;
}};
var k=function(AG,AN,AQ,AE,AS,AJ){if(AE["/freebase/type_hints/mediator"]==true){AN.className+=" topic-view-nested-property-container";
var AW=G.ui.createHTMLElement("table");
AW.className="topic-view-nested-table";
AW.setAttribute("border","0");
AW.setAttribute("cellspacing","0");
AW.setAttribute("cellpadding","0");
AW.setAttribute("width","100%");
AN.appendChild(AW);
var AC="";
if("master_property" in AG){AC=AG.master_property.id;
}var AF=AE.properties;
var AX={};
var AD=AW.insertRow(0);
AD.vAlign="top";
for(var AU=0;
AU<AF.length;
AU++){var AI=AF[AU];
var AK=AD.insertCell(AU);
AK.innerHTML=AI.name;
AK.className="topic-view-nested-property-label";
AX[AI.id]=0;
}for(var AV=0;
AV<AQ.length;
AV++){var d=AQ[AV];
var t=AW.insertRow(AV+1);
t.vAlign="top";
for(var AU=0;
AU<AF.length;
AU++){var AK=t.insertCell(AU);
AK.className="topic-view-nested-property-value-container";
var AI=AF[AU];
var AP=AI.id;
if(AP in d){var AM=d[AP];
if(AM.length>0){var o=AS.concat(AP);
k(AI,AK,AM,AI.expected_type,o,true);
AX[AI.id]+=AM.length;
continue;
}}AK.innerHTML="&nbsp;";
}}var AZ=function(Ab,j){var Aa=AS.concat(j.id);
Ab.innerHTML="&raquo;&nbsp;";
var i=G.ui.createHTMLElement("a");
i.href="javascript:{}";
i.innerHTML="browse&nbsp;all";
i.onclick=function(){Logging.log("topic-to-cvt-column",{path:b(Aa)});
Q._callbacks.onPivot(Aa,j.name);
};
Ab.appendChild(i);
};
var AT=AW.insertRow(AW.rows.length);
AT.vAlign="top";
for(var AU=0;
AU<AF.length;
AU++){var AI=AF[AU];
var AK=AT.insertCell(AU);
AK.className="topic-view-browse-all";
if(AX[AI.id]>0&&!G.freebase.schemas.isNativeType(AI.expected_type.id)){AZ(AK,AI);
}else{AK.innerHTML="&nbsp;";
}}var AL=AW.insertRow(AW.rows.length);
var AH=AL.insertCell(0);
AH.colSpan=AF.length;
var AO=G.ui.createHTMLElement("div");
AH.appendChild(AO);
AO.className="topic-view-add";
AO.appendChild(f(AS,AE.id,AF));
}else{AN.className+=" topic-view-property-value-container";
for(var AV=0;
AV<AQ.length;
AV++){var d=AQ[AV];
var AR=G.ui.createHTMLElement("div");
P(AR,d);
AN.appendChild(AR);
}if(AQ.length>1){var AR=G.ui.createHTMLElement("div");
AR.className="topic-view-browse-all";
AR.innerHTML="&raquo;&nbsp;";
AN.appendChild(AR);
var AY=G.ui.createHTMLElement("a");
AY.href="javascript:{}";
AY.innerHTML="browse&nbsp;all";
AY.onclick=function(){Logging.log("topic-to-property-values",{path:b(AS)});
Q._callbacks.onPivot(AS,AG.name);
};
AR.appendChild(AY);
}if(!AJ&&!AG.unique){var AO=G.ui.createHTMLElement("div");
AR.appendChild(AO);
AO.className="topic-view-add";
AO.appendChild(x(AS,AE.id));
}}};
var g=function(o,d){var t=o.insertRow(o.rows.length);
t.vAlign="top";
var j=t.insertCell(0);
j.innerHTML=d.name;
j.title=d.id;
j.className="topic-view-property-label";
var i=t.insertCell(1);
k(d,i,d.data,d.expected_type,[d.id],false);
};
var S=G.ui.createHTMLElement("div");
S.style.marginRight="20px";
S.innerHTML='<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr valign="top"><td width="10%"></td><td></td></tr></table>';
AB.appendChild(S);
var s=S.firstChild.rows[0].cells[0];
s.className="topic-view-tab-header-container";
var O=S.firstChild.rows[0].cells[1];
O.className="topic-view-tab-body-container";
var Z=function(d){for(var j=0;
j<s.childNodes.length;
j++){if(d==j){s.childNodes[j].className="topic-view-tab-header topic-view-tab-header-selected";
O.childNodes[j].style.display="block";
}else{s.childNodes[j].className="topic-view-tab-header";
O.childNodes[j].style.display="none";
}}};
var m=function(i){var d=s.childNodes.length;
var t=i.indexOf(" (");
if(t>0){i=i.substr(0,t);
}var o=G.ui.createHTMLElement("div");
o.innerHTML=i;
o.className=d==0?"topic-view-tab-header topic-view-tab-header-selected":"topic-view-tab-header";
o.onclick=function(){Logging.log("topic-select-tab",{"label":i});
Z(d);
};
s.appendChild(o);
var j=G.ui.createHTMLElement("div");
j.className="topic-view-tab-body";
j.style.display=d==0?"block":"none";
O.appendChild(j);
return j;
};
var r=G.ui.createHTMLElement("div");
r.className="topic-view-essential-section";
r.innerHTML='<table width="100%" border="0" cellspacing="0" cellpadding="0" class="topic-view-table"></table>';
for(var y=0;
y<I.length;
y++){g(r.firstChild,I[y]);
}for(var y=0;
y<R.length;
y++){g(r.firstChild,R[y]);
}M.insertBefore(r,M.firstChild);
N.sort(function(i,d){return d.propertyEntries.length-i.propertyEntries.length;
});
for(var y=0;
y<N.length;
y++){var u=N[y];
var X=m("As "+u.typeEntry.name);
X.innerHTML='<table border="0" cellspacing="0" cellpadding="0" class="topic-view-table"></table>';
for(var v=0;
v<u.propertyEntries.length;
v++){g(X.firstChild,u.propertyEntries[v]);
}}for(var y=0;
y<J.length;
y++){var p=J[y];
var W=m(p.name);
W.innerHTML='<table border="0" cellspacing="0" cellpadding="0" class="topic-view-table"></table>';
k(p,W,p.data,p.expected_type,[p.id],false);
}var a=m("More...");
a.innerHTML='<table border="0" cellspacing="0" cellpadding="0" class="topic-view-table"></table>';
var n=a.firstChild;
for(var y=0;
y<w.length;
y++){var u=w[y];
var z=n.insertRow(n.rows.length);
var K=z.insertCell(0);
K.className="topic-view-type-section";
K.setAttribute("colspan","2");
K.innerHTML=u.typeEntry.name;
for(var v=0;
v<u.propertyEntries.length;
v++){g(n,u.propertyEntries[v]);
}}this._callbacks.onRender();
};
B.prototype.uninstallUI=function(){if(this._outerDiv!=null){this._outerDiv=null;
}};
B.prototype.dispose=function(){this.uninstallUI();
};
function F(H,S,M,I){var J=[];
var N=I.offsetWidth;
var L=C();
var Q=D(I,5,5);
Q.innerHTML='<div style="padding: 5px; background: #444;"><div style="width: '+N+'px; font-style: italic;"><table width="100%" cellspacing="10" style="color: white;"><tr valign="top"><td colspan="2">Start typing something and we\'ll guess what you mean...</td></tr><tr valign="top"><td><button>Cancel</button></td><td align="right"><button>Done Adding</button></td></tr></table></div>';
"</div>";
var O=function(){Q.parentNode.removeChild(Q);
L();
};
var K=function(){for(var T=0;
T<J.length;
T++){var U=J[T];
var W={"id":H};
var V={"connect":"insert"};
W[S[0]]=V;
if(U.topicID!=null){V["id"]=U.topicID;
}else{if(U.topicName!=null){V["create"]="unless_exists";
V["id"]=null;
V["type"]=M;
V["name"]=U.topicName;
}else{if(U.value!=null){V["value"]=U.value;
}else{continue;
}}}ChangeManager.addChange(W);
}O();
};
var R=Q.getElementsByTagName("button");
R[0].onclick=O;
R[1].onclick=K;
var P=function(){var V=J.length;
var W=G.ui.createHTMLElement("div");
W.style.width=N+"px";
W.style.marginBottom="5px";
Q.firstChild.insertBefore(W,Q.firstChild.lastChild);
var U={ac_param:{type:M},soft:false,suggest_new:"Create new topic"};
var T=new E(W,function(){if(V+1<J.length){J[V+1].focus();
}else{P();
}},U);
T.focus();
J.push(T);
return T;
};
P();
}function A(H,X,P,L,O){var M=[];
var I=[];
var W=O.parentNode.previousSibling;
for(var Q=0;
Q<W.cells.length;
Q++){I.push(W.cells[Q].offsetWidth);
}var N=O.offsetWidth;
var K=C();
var U=D(O,5,5);
U.innerHTML='<div style="padding: 5px; background: #444;"><table width="'+N+'" cellspacing="0" cellpadding="0"></table><div style="width: '+N+'px; font-style: italic;"><table width="100%" cellspacing="10" style="color: white;"><tr valign="top"><td colspan="2">Start typing something and we\'ll guess what you mean...</td></tr><tr valign="top"><td><button>Cancel</button></td><td align="right"><button>Done Adding</button></td></tr></table></div>';
"</div>";
var S=function(){U.parentNode.removeChild(U);
K();
};
var J=function(){for(var c=0;
c<M.length;
c++){var e=M[c];
var g=false;
var d=e.ves;
for(var a=0;
a<d.length;
a++){if(d[a].hasInput()){g=true;
break;
}}if(!g){continue;
}var b={"create":"unconditional","type":P};
var f={"id":H};
f[X[0]]=b;
for(var a=0;
a<d.length;
a++){var Z=d[a];
var Y={"connect":"insert"};
if(Z.topicID!=null){Y["id"]=Z.topicID;
}else{if(Z.topicName!=null){Y["create"]="unless_exists";
Y["id"]=null;
Y["type"]=P;
Y["name"]=Z.topicName;
}else{if(Z.value!=null){Y["value"]=Z.value;
}else{continue;
}}}b[L[a].id]=Y;
}ChangeManager.addChange(f);
}S();
};
var V=U.getElementsByTagName("button");
V[0].onclick=S;
V[1].onclick=J;
var R=function(e,c,d,Z){var b=G.ui.createHTMLElement("div");
d.appendChild(b);
var a={ac_param:{type:Z.expected_type.id},soft:false,suggest_new:"Create new topic"};
var Y=new E(b,function(){if(c+1<L.length){M[e].ves[c+1].focus();
}else{if(e+1<M.length){M[e+1].ves[0].focus();
}else{T();
}}},a);
return Y;
};
var T=function(){var Z=M.length;
var b=U.firstChild.firstChild;
var c=b.insertRow(b.rows.length);
var e=[];
for(var a=0;
a<L.length;
a++){var d=c.insertCell(a);
d.width=I[a];
var Y=R(Z,a,d,L[a]);
e.push(Y);
}M.push({ves:e});
e[0].focus();
};
T();
}function C(){var J=G.ui.createHTMLElement("div");
J.style.height="500px";
J.innerHTML="&nbsp;";
document.body.appendChild(J);
var H=document.body.scrollWidth;
var K=document.body.scrollHeight;
var I=G.ui.createHTMLElement("div");
I.style.position="absolute";
I.style.top="0px";
I.style.left="0px";
I.style.width=H+"px";
I.style.height=K+"px";
I.style.background="black";
I.style.opacity=0.5;
I.style.zIndex=100;
document.body.appendChild(I);
return function(){document.body.removeChild(J);
document.body.removeChild(I);
};
}function D(J,I,H){var L=SimileAjax.DOM.getPageCoordinates(J);
var K=G.ui.createHTMLElement("div");
K.style.position="absolute";
K.style.top=(L.top+J.offsetHeight)+"px";
K.style.left=(L.left-I)+"px";
K.style.width=(J.offsetWidth+16+2*I)+"px";
K.style.height=(500+2*H)+"px";
K.style.overflow="auto";
K.style.zIndex=200;
document.body.appendChild(K);
return K;
}function E(K,H,J){this.topicID=null;
this.topicName=null;
this.value=null;
this._input=G.ui.createHTMLElement("input");
this._input.style.width="100%";
K.appendChild(this._input);
var I=this;
if(J.ac_param.type in SchemaUtil.nativeTypes){this._input.onkeypress=function(L){I.value=I._input.value;
if(L.keyCode==13){H();
}};
}else{$(this._input).freebaseSuggest(J).bind("fb-select",function(M,L){I.topicID=L.id;
I.topicName=null;
H();
}).bind("fb-select-new",function(M,L){I.topicID=null;
I.topicName=L.name;
H();
});
}}E.prototype.focus=function(){this._input.focus();
};
E.prototype.hasInput=function(){return this.topicID!=null||this.topicName!=null||this.value!=null;
};
})();


/* topic-thumbnail-rendering.js */
(function(){var C=window.MetawebSuite;
if(!("renderings" in C.ui)){C.ui.renderings={};
}var B=function(D){return D.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");
};
var A=C.ui.renderings.TopicThumbnailRendering=function(E,D){this._itemID=E;
this._callbacks=D;
};
A.prototype.installUI=function(H){this._div=H;
var D=this;
var G=this._itemID;
var F=function(K){if(D._div!=H){return ;
}var I=K.name;
var S=null;
if("description" in K){var P=K.description.split("\\n");
for(var N=P.length-1;
N>=0;
N--){var O=P[N];
if(O.length==0){P.splice(N,1);
}}if(P.length>0){S="";
for(var N=0;
N<P.length;
N++){var O=P[N];
if(N==P.length-1){O+=" ...";
}S+="<p>"+B(O)+"</p>";
}}}var J=C.freebase.location+"view"+G;
H.innerHTML="<div class='freebase-hotshot-container'><table><tr valign='top'><td><div>"+("name" in K?("<h1 class='freebase-hotshot-name'><a href='"+J+"'>"+I+"</a></h1>"):("<h1 class='freebase-hotshot-id'><a href='"+J+"'>"+G+"</a></h1>"))+"</div>"+((S!=null)?("<div class='freebase-hotshot-blurb'>"+S+"</div>"):"")+"</td><td></td></tr></table></div>";
if("onFocus" in D._callbacks){myJQuery(H.firstChild.firstChild.rows[0].cells[0].childNodes[0].childNodes[0]).click(function(T){try{window.top.Logging.log("thumbnail-to-topic",{"id":G});
}catch(U){}D._callbacks.onFocus(G,I);
return C.ui.cancelEvent(T);
});
}if("thumbnails" in K){var M=K.thumbnails;
var Q=H.firstChild.firstChild.rows[0].cells[1];
for(var N=0;
N<M.length;
N++){var R=M[N];
var L=C.ui.createHTMLElement("div");
L.className="freebase-hotshot-thumbnail";
L.innerHTML="<img src='"+R.url+"' title='"+R.title+"' />";
if("onThumbnail" in D._callbacks){myJQuery(L.firstChild).click(function(T){return D._callbacks.onThumbnail(this,T);
});
}Q.appendChild(L);
}}if(typeof D._callbacks.onRender=="function"){D._callbacks.onRender();
}};
var E="http://hotshot.dfhuynh.user.dev."+C.freebase.appsDomain+"/acre/json?id="+encodeURIComponent(G);
C.freebase.mql.getJsonpQueue().call(E,F,C.system.exception);
};
A.prototype.uninstallUI=function(){if(this._div!=null){this._div=null;
}};
A.prototype.dispose=function(){this.uninstallUI();
};
})();


/* terminal.js */
window.MetawebSuite.system.onFinishLoadingPackage("metaweb-suite-topic-renderings");


/* views-package.js */
(function() {
    mw.system.onStartLoadingNativePackage(
        "views",
        [   "view-util.js",
            "thumbnail-view.js",
            "single-topic-view.js",
            "map-view/map-view.js",
            "map-view/map-view-querying.js",
            "timeline-view/timeline-view.js",
            "timeline-view/timeline-view-worker.js",
            "chart-1d-view/chart-1d-view.js",
            "chart-1d-view/chart-1d-view-worker.js",
            "chart-2d-view/chart-2d-view.js",
            "chart-2d-view/chart-2d-view-worker.js",
            "tabular-view/tabular-view.js",
            "tabular-view/tabular-view-worker.js",
            "terminal.js"
        ],
        [   "views.css",
            "views/map-view.css",
            "views/timeline-view.css",
            "views/chart1d-view.css",
            "views/chart2d-view.css",
            "views/tabular-view.css"
        ]
    );
})();


/* views-bundle.js */


/* chart-1d-view-worker.js */
function chart1DViewQuery(B,C){var N=[B.valuePath];
if(B.hasColor){N.push(B.colorPath);
}if(B.hasPointLabel){N.push(B.pointLabelPath);
}var L=extractProxyPath(N);
var A=createForwardPathIterator(L);
B.valuePath=removeProxyPath(B.valuePath,L);
var H=createForwardPathIterator(B.valuePath);
if(B.hasColor){B.colorPath=removeProxyPath(B.colorPath,L);
var G=createForwardPathIterator(B.colorPath);
}if(B.hasPointLabel){B.pointLabelPath=removeProxyPath(B.pointLabelPath,L);
var K=createForwardPathIterator(B.pointLabelPath);
}var M=B.queryNode;
M["limit"]=1000;
var J=extendQueryNodeWithPath(M,L);
if(J!=M&&B.valuePath.length>0){J["name"]=null;
}var E=extendQueryNodeWithPath(J,B.valuePath);
E["value"]=null;
if(B.hasPointLabel){var F=extendQueryNodeWithPath(J,B.pointLabelPath);
if(B.pointLabelTypeIsNative){if(!("value" in F)){F["value"]=null;
}}else{if(!("name" in F)){F["name"]=null;
}}}if(B.hasColor){var I=extendQueryNodeWithPath(J,B.colorPath);
if(!("name" in I)){I["name"]=null;
}makeQueryNodeOptionalIfEmpty(I);
}var D=function(T){var R=[];
var P=B.colorKeys;
B.hasColorKeys=false;
var O=function(V){var X=V.value;
if(typeof X=="string"){try{X=parseFloat(X);
}catch(W){}}if(typeof X=="number"&&!isNaN(X)){return X;
}else{return null;
}};
var S=function(a,X){var V={value:null,itemID:a.id,itemName:a.name};
H(X,function(b){V.value=O(b);
});
if(V.value==null){return ;
}if(B.hasColor){var Y=null;
G(X,function(b){Y=b;
});
if(Y!=null){var Z=Y.name;
var W=B.colorCoder.getColorForKey(Z);
P[Z]=true;
B.hasColorKeys=true;
V.color=W;
}}if(B.hasPointLabel){K(X,function(b){if(b.name!=null){V.proxyLabel=b.name;
}else{if(b.value!=null){V.proxyLabel=b.value;
}}});
}R.push(V);
};
for(var Q=0;
Q<T.result.length;
Q++){var U=T.result[Q];
A(U,function(V){S(U,V);
});
}R.sort(function(W,V){return V.value-W.value;
});
C(R);
};
JsonpQueue.queryOne([M],D,genericErrorHandler);
}function chart1DViewPlot(X,U,a){if(U.length==0){X.innerHTML="";
return ;
}var B=30;
var c=200;
var S=B*U.length;
X.innerHTML='<div style="position: relative; margin: 5px; margin-left: '+c+"px; height: "+S+'px;"></div>';
var Z=X.firstChild;
var I=Z.offsetWidth;
var G=function(){var e=document.createElement("div");
e.className="chart1d-view-layer";
e.innerHTML='<div class="chart1d-view-layer-inner"></div>';
Z.appendChild(e);
return e.firstChild;
};
var Q=Number.POSITIVE_INFINITY;
var b=Number.NEGATIVE_INFINITY;
for(var V=0;
V<U.length;
V++){var M=U[V].value;
Q=Math.min(Q,M);
b=Math.max(b,M);
}var A=1;
var Y=b-Q;
if(Y>1){while(A*20<Y){A*=10;
}if(Y/A<4){A/=2;
}}else{while(A<Y*20){A/=10;
}if(Y/A<4){A/=2;
}}var K=Math.floor(Q/A)*A;
var N=Math.ceil(b/A)*A;
var d=I/(N-K);
var C=G();
C.style.border="1px solid #eee";
for(var L=K;
L<N;
L+=A){var E=Math.floor((L-K)*d);
var J=document.createElement("div");
J.className="chart1d-view-vertical-grid-line";
J.style.left=E+"px";
C.appendChild(J);
var H=L;
if(L>1000000000){H=(Math.floor(L/100000000)/10)+"B";
}else{if(L>1000000){H=(Math.floor(L/100000)/10)+"M";
}else{if(L>1000){H=(Math.floor(L/100)/10)+"K";
}else{if(L>1){H=L;
}else{if(L>0.001){H=(Math.floor(L/0.0001)/10)+"m";
}else{if(L>0.000001){H=(Math.floor(L/1e-7)/10)+"u";
}}}}}}var W=document.createElement("div");
W.className="chart1d-view-vertical-grid-label";
W.style.left=E+"px";
W.style.top=(S+5)+"px";
W.innerHTML=H;
C.appendChild(W);
}var D=G();
var R=G();
var O=G();
var F=function(k,j){var l=document.createElement("div");
l.className="chart1d-view-vertical-data-label";
l.style.top=j+"px";
l.style.left=-c+"px";
l.style.width=c+"px";
l.style.height=B+"px";
l.innerHTML='<div style="padding-right: 5px;">'+k.itemName+"</div>";
D.appendChild(l);
var n=k.itemName!=null?k.itemName:"";
if("proxyLabel" in k&&k.proxyLabel!=null){n+=" ("+k.proxyLabel+")";
}if(n.length>0){n+=": ";
}n+=formatNumberWithSeparators(k.value);
var f=Math.floor((k.value-K)*d);
var g=("color" in k)?k.color:a.getDefaultColor();
var i=7;
var m=i*2;
var h=SimileAjax.Graphics.createTranslucentImage("http://simile.mit.edu/painter/painter?"+["renderer=map-marker","pin=false","borderThickness=1","borderColor="+g.substr(1),"shape=circle","width="+m,"height="+m,"background="+g.substr(1)].join("&"),"middle");
h.className="chart1d-view-data-point";
h.style.top=(j+Math.floor(B/2)-i)+"px";
h.style.left=(f-i)+"px";
h.title=n;
O.appendChild(h);
if("proxyLabel" in k&&k.proxyLabel!=null){var e=document.createElement("div");
e.style.top=(j+Math.floor(B/2)-i)+"px";
if(f>I/2){e.className="chart1d-view-vertical-data-point-label-left";
e.style.right=(I-f+i+2)+"px";
}else{e.className="chart1d-view-vertical-data-point-label-right";
e.style.left=(f+i+2)+"px";
}e.innerHTML=k.proxyLabel;
R.appendChild(e);
}};
for(var V=0;
V<U.length;
V++){var T=U[V];
var P=V*B;
F(T,P);
}}

/* chart-1d-view.js */
function Chart1DView(B,A){this.collection=B;
this._label=A;
this._div=null;
this._dom=null;
this._colorCoder=new DefaultColorCoder();
this._valuePropertyPicker=new mw.ui.widgets.DimensionPathPickerWidget(false,true,false);
this._pointLabelPropertyPicker=new mw.ui.widgets.DimensionPathPickerWidget(false,true,false);
this._colorPropertyPicker=new mw.ui.widgets.DimensionPathPickerWidget(false,true,false);
this._setBaseRestrictionsToPropertyPickers();
this.collection.addListener(this);
}Chart1DView.prototype.getLabel=function(){return(typeof this._label=="string")?("Chart 1D ("+this._label+")"):"Chart 1D";
};
Chart1DView.prototype.dispose=function(){this._valuePropertyPicker.dispose();
this._valuePropertyPicker=null;
this._pointLabelPropertyPicker.dispose();
this._pointLabelPropertyPicker=null;
this._colorPropertyPicker.dispose();
this._colorPropertyPicker=null;
this._div=null;
this._dom=null;
this.collection.removeListener(this);
this.collection=null;
};
Chart1DView.prototype.getState=function(){return{v:this._valuePropertyPicker.getState(),pl:this._pointLabelPropertyPicker.getState(),c:this._colorPropertyPicker.getState()};
};
Chart1DView.prototype.getClassName=function(){return"Chart1DView";
};
Chart1DView.prototype.reconfigureFromState=function(A){this._valuePropertyPicker.reconfigureFromState(A.v);
this._pointLabelPropertyPicker.reconfigureFromState(A.pl);
this._colorPropertyPicker.reconfigureFromState(A.c);
};
Chart1DView.prototype.installUI=function(A){this._div=A;
this._constructUI();
this._reRender();
};
Chart1DView.prototype.uninstallUI=function(){this._valuePropertyPicker.uninstallUI();
this._pointLabelPropertyPicker.uninstallUI();
this._colorPropertyPicker.uninstallUI();
this._div.innerHTML="";
this._div=null;
this._dom=null;
};
Chart1DView.prototype.onModeChanged=function(A){};
Chart1DView.prototype._getColorForKey=function(B){if(B in this._colorMap){return this._colorMap[B];
}else{var A=this._colorMap[B]=Chart1DView.defaultColors[this._colorMax];
this._colorMax=(this._colorMax+1)%Chart1DView.defaultColors.length;
return A;
}};
Chart1DView.prototype._constructUI=function(){var A=this;
this._div.innerHTML='<div id="results-summary-container"></div><div class="chart1d-view-controls"><table width="100%" cellspacing="10"><tr><td width="10%">What&nbsp;to&nbsp;Plot:</td><td colspan="2"></td></tr><tr><td width="10%">How&nbsp;to&nbsp;Label&nbsp;Points:</td><td colspan="2"></td></tr><tr><td width="10%">Color&nbsp;Coding:</td><td></td colspan="2"></tr><tr><td colspan="2"><button>Render&nbsp;Chart</button></td><td width="10%"<a href="javascript:{}" class="action">embed&nbsp;this&nbsp;chart</a></td></tr></table></div><div class="chart1d-view-canvas"></div><div class="chart1d-view-legend"></div>';
this._dom={viewSummaryContainer:this._div.childNodes[0],controlTable:this._div.childNodes[1].childNodes[0],canvasDiv:this._div.childNodes[2],legendDiv:this._div.childNodes[3],ready:false};
this._valuePropertyPicker.installUI(this._dom.controlTable.rows[0].cells[1]);
this._pointLabelPropertyPicker.installUI(this._dom.controlTable.rows[1].cells[1]);
this._colorPropertyPicker.installUI(this._dom.controlTable.rows[2].cells[1]);
this._dom.controlTable.rows[3].cells[0].firstChild.onclick=function(){Logging.log("chart1d-view-re-render",{"state":A.getState()});
A._reRender();
};
this._dom.controlTable.rows[3].cells[1].firstChild.onclick=function(){Logging.log("chart1d-view-embed",{});
A._embed();
};
};
Chart1DView.prototype.onItemsChanged=function(){this._reRender();
};
Chart1DView.prototype.onRootItemsChanged=function(){this._setBaseRestrictionsToPropertyPickers();
};
Chart1DView.prototype._setBaseRestrictionsToPropertyPickers=function(){this._valuePropertyPicker.setBaseQueryNode(this.collection.addBaseRestrictions());
this._pointLabelPropertyPicker.setBaseQueryNode(this.collection.addBaseRestrictions());
this._colorPropertyPicker.setBaseQueryNode(this.collection.addBaseRestrictions());
};
Chart1DView.prototype._reRender=function(){if(this._div!=null){this._dom.viewSummaryContainer.innerHTML="";
this._dom.legendDiv.innerHTML="";
this._startRenderView();
}};
Chart1DView.prototype._createJob=function(){var A={"id":null,"name":null};
this.collection.addRestrictions(A);
var B={queryNode:A,valuePath:this._valuePropertyPicker.getTotalPath(),hasColor:this._colorPropertyPicker.specified,hasPointLabel:this._pointLabelPropertyPicker.specified};
if(B.hasColor){B.colorPath=this._colorPropertyPicker.getTotalPath();
}if(B.hasPointLabel){B.pointLabelPath=this._pointLabelPropertyPicker.getTotalPath();
B.pointLabelTypeIsNative=this._pointLabelPropertyPicker.getExpectedType() in SchemaUtil.nativeTypes;
}return B;
};
Chart1DView.prototype._startRenderView=function(){ViewUtil.renderViewSummary(this.collection,this._dom.viewSummaryContainer);
var A=this;
if(!this._valuePropertyPicker.specified){return ;
}var B=this._createJob();
B.colorCoder=this._colorCoder;
B.colorKeys={};
var A=this;
chart1DViewQuery(B,function(E){chart1DViewPlot(A._dom.canvasDiv,E,A._colorCoder);
if(B.hasColorKeys){for(var D in B.colorKeys){var C=A._colorCoder.getColorForKey(D);
var F=mw.ui.createHTMLElement("div");
F.className="chart1d-view-legend-entry";
F.appendChild(SimileAjax.Graphics.createTranslucentImage("http://simile.mit.edu/painter/painter?"+["renderer=map-marker","pin=false","borderThickness=1","borderColor="+C.substr(1),"shape=circle","width=15","height=15","background="+C.substr(1)].join("&"),"middle"));
F.appendChild(document.createTextNode(D));
A._dom.legendDiv.appendChild(F);
}}});
};
Chart1DView.prototype._embed=function(){var D=this._createJob();
var A=document.location.href;
var C=A.indexOf("browse.html");
A=A.substr(0,C)+"chart-1d-view-embed.html?"+encodeURIComponent(JSON.stringify(D));
var B='<iframe height="600" width="100%" src="'+A+'"></iframe>';
window.prompt("HTML code to copy:",B);
};


/* chart-2d-view-worker.js */
function chart2DViewQuery(G,F){var M=[G.xValuePath,G.yValuePath];
if(G.hasSize){M.push(G.sizePath);
}if(G.hasColor){M.push(G.colorPath);
}if(G.hasPointLabel){M.push(G.pointLabelPath);
}var Q=extractProxyPath(M);
var H=createForwardPathIterator(Q);
G.xValuePath=removeProxyPath(G.xValuePath,Q);
var E=createForwardPathIterator(G.xValuePath);
G.yValuePath=removeProxyPath(G.yValuePath,Q);
var D=createForwardPathIterator(G.yValuePath);
if(G.hasSize){G.sizePath=removeProxyPath(G.sizePath,Q);
var J=createForwardPathIterator(G.sizePath);
}if(G.hasColor){G.colorPath=removeProxyPath(G.colorPath,Q);
var A=createForwardPathIterator(G.colorPath);
}if(G.hasPointLabel){G.pointLabelPath=removeProxyPath(G.pointLabelPath,Q);
var K=createForwardPathIterator(G.pointLabelPath);
}var N=G.queryNode;
N["limit"]=1000;
var P=extendQueryNodeWithPath(N,Q);
var I=extendQueryNodeWithPath(P,G.xValuePath);
I["value"]=null;
var B=extendQueryNodeWithPath(P,G.yValuePath);
B["value"]=null;
if(G.hasSize){var R=extendQueryNodeWithPath(P,G.sizePath);
R["value"]=null;
}if(G.hasPointLabel){var C=extendQueryNodeWithPath(P,G.pointLabelPath);
if(G.pointLabelTypeIsNative){if(!("value" in C)){C["value"]=null;
}}else{if(!("name" in C)){C["name"]=null;
}}}if(G.hasColor){var O=extendQueryNodeWithPath(P,G.colorPath);
makeQueryNodeOptionalIfEmpty(O);
if(!("name" in O)){O["name"]=null;
}}var L=function(X){var V=[];
var T=G.colorKeys;
G.hasColorKeys=false;
var S=function(Z){var b=Z.value;
if(typeof b=="string"){try{b=parseFloat(b);
}catch(a){}}if(typeof b=="number"&&!isNaN(b)){return b;
}else{return null;
}};
var W=function(e,b){var Z={itemID:e.id,itemName:e.name,x:null,y:null,size:null};
E(b,function(f){Z.x=S(f);
});
D(b,function(f){Z.y=S(f);
});
if(Z.x==null||Z.y==null){return ;
}if(G.hasSize){J(b,function(f){Z.size=S(f);
});
}if(G.hasColor){var c=null;
A(b,function(f){c=f;
});
if(c!=null){var d=c.name;
var a=G.colorCoder.getColorForKey(d);
T[d]=true;
G.hasColorKeys=true;
Z.color=a;
}}if(G.hasPointLabel){K(b,function(f){if(f.name!=null){Z.proxyLabel=f.name;
}else{if(f.value!=null){Z.proxyLabel=f.value;
}}});
}V.push(Z);
};
for(var U=0;
U<X.result.length;
U++){var Y=X.result[U];
H(Y,function(Z){W(Y,Z);
});
}F(V);
};
JsonpQueue.queryOne([N],L,genericErrorHandler);
}function chart2DViewPlot(L,g,z,X,c,Q){if(g.length==0){L.innerHTML="";
return ;
}var m=150;
L.innerHTML='<div style="position: relative; margin: 5px; margin-left: '+m+"px; height: "+X+'px;"></div>';
var I=L.firstChild;
var F=I.offsetWidth;
var r=function(){var i=mw.ui.createHTMLElement("div");
i.className="chart2d-view-layer";
i.innerHTML='<div class="chart2d-view-layer-inner"></div>';
I.appendChild(i);
return i.firstChild;
};
var v=Number.POSITIVE_INFINITY;
var N=Number.NEGATIVE_INFINITY;
var R=Number.POSITIVE_INFINITY;
var o=Number.NEGATIVE_INFINITY;
var AA=Number.POSITIVE_INFINITY;
var V=Number.NEGATIVE_INFINITY;
var T=false;
for(var w=0;
w<g.length;
w++){var t=g[w];
var k=t.x;
var h=t.y;
v=Math.min(v,k);
N=Math.max(N,k);
R=Math.min(R,h);
o=Math.max(o,h);
if(t.size!=null){T=true;
var q=t.size;
AA=Math.min(AA,q);
V=Math.max(V,q);
}}var e=1;
var W=N-v;
if(W>1){while(e*20<W){e*=10;
}if(W/e<4){e/=2;
}}else{while(e<W*20){e/=10;
}if(W/e<4){e/=2;
}}var a=Math.floor(v/e)*e;
var E=Math.ceil(N/e)*e;
var P=F/(E-a);
var D=1;
var O=o-R;
if(O>1){while(D*20<O){D*=10;
}if(O/D<4){D/=2;
}}else{while(D<O*20){D/=10;
}if(O/D<4){D/=2;
}}var d=Math.floor(R/D)*D;
var J=Math.ceil(o/D)*D;
var u=X/(J-d);
var j=50;
var l=5;
if(T){var AB=V-AA;
var C=Math.sqrt(AB);
var B=(j-l)/C;
}var U=r();
U.style.border="1px solid #eee";
for(var k=a+e;
k<E;
k+=e){var G=Math.floor((k-a)*P);
var K=mw.ui.createHTMLElement("div");
K.className="chart2d-view-vertical-grid-line";
K.style.left=G+"px";
U.appendChild(K);
var S=formatNumberWithSuffix(k);
var Y=mw.ui.createHTMLElement("div");
Y.className="chart2d-view-vertical-grid-label";
Y.style.left=G+"px";
Y.style.top=(X+5)+"px";
Y.innerHTML=S;
U.appendChild(Y);
}for(var h=d+D;
h<J;
h+=D){var H=X-Math.floor((h-d)*u);
var K=mw.ui.createHTMLElement("div");
K.className="chart2d-view-horizontal-grid-line";
K.style.top=H+"px";
U.appendChild(K);
var A=formatNumberWithSuffix(h);
var Y=mw.ui.createHTMLElement("div");
Y.className="chart2d-view-horizontal-grid-label";
Y.style.top=H+"px";
Y.style.right=(F+5)+"px";
Y.innerHTML=A;
U.appendChild(Y);
}c(function(p){var i=mw.ui.createHTMLElement("div");
i.className="chart2d-view-horizontal-axis-label";
i.style.top=X+"px";
i.style.right="0px";
i.innerHTML=p;
U.appendChild(i);
});
Q(function(p){var i=mw.ui.createHTMLElement("div");
i.className="chart2d-view-vertical-axis-label";
i.style.top="0px";
i.style.right=(F+5)+"px";
i.innerHTML=p;
U.appendChild(i);
});
var M=r();
var Z=r();
var n=r();
var f=function(AD,AC){var p=Math.floor((AD.x-a)*P);
var AC=X-Math.floor((AD.y-d)*u);
var AF=AD.itemName!=null?AD.itemName:"";
if("proxyLabel" in AD&&AD.proxyLabel!=null){AF+=" ("+AD.proxyLabel+")";
}if(AF.length>0){AF+=": ";
}AF+=formatNumberWithSeparators(AD.x)+" x "+formatNumberWithSeparators(AD.y);
var s=("color" in AD)?AD.color:z.getDefaultColor();
var y=7;
if(T&&AD.size!=null){y=Math.round(l+Math.sqrt(AD.size-AA)*B);
}var AE=y*2;
var x=SimileAjax.Graphics.createTranslucentImage("http://simile.mit.edu/painter/painter?"+["renderer=map-marker","pin=false","borderThickness=1","borderColor="+s.substr(1),"shape=circle","width="+AE,"height="+AE,"background="+s.substr(1)].join("&"),"middle");
x.className="chart2d-view-data-point";
x.style.top=(AC-y)+"px";
x.style.left=(p-y)+"px";
x.title=AF;
n.appendChild(x);
if("proxyLabel" in AD&&AD.proxyLabel!=null){var i=mw.ui.createHTMLElement("div");
i.style.top=AC+"px";
if(p>F/2){i.className="chart2d-view-data-point-label-left";
i.style.right=(F-p+y+2)+"px";
}else{i.className="chart2d-view-data-point-label-right";
i.style.left=(p+y+2)+"px";
}i.innerHTML=AD.proxyLabel;
Z.appendChild(i);
}};
for(var w=0;
w<g.length;
w++){var b=g[w];
f(b);
}}

/* chart-2d-view.js */
function Chart2DView(B,A){this.collection=B;
this._label=A;
this._div=null;
this._dom=null;
this._colorCoder=new DefaultColorCoder();
this._xValuePropertyPicker=new mw.ui.widgets.DimensionPathPickerWidget(false,true,false);
this._yValuePropertyPicker=new mw.ui.widgets.DimensionPathPickerWidget(false,true,false);
this._sizeValuePropertyPicker=new mw.ui.widgets.DimensionPathPickerWidget(false,true,false);
this._pointLabelPropertyPicker=new mw.ui.widgets.DimensionPathPickerWidget(false,true,false);
this._colorPropertyPicker=new mw.ui.widgets.DimensionPathPickerWidget(false,true,false);
this._setBaseRestrictionsToPropertyPickers();
this.collection.addListener(this);
}Chart2DView.prototype.getLabel=function(){return(typeof this._label=="string")?("Chart 2D ("+this._label+")"):"Chart 2D";
};
Chart2DView.prototype.dispose=function(){this._xValuePropertyPicker.dispose();
this._xValuePropertyPicker=null;
this._yValuePropertyPicker.dispose();
this._yValuePropertyPicker=null;
this._sizeValuePropertyPicker.dispose();
this._sizeValuePropertyPicker=null;
this._pointLabelPropertyPicker.dispose();
this._pointLabelPropertyPicker=null;
this._colorPropertyPicker.dispose();
this._colorPropertyPicker=null;
this._div=null;
this._dom=null;
this.collection.removeListener(this);
this.collection=null;
};
Chart2DView.prototype.getState=function(){return{x:this._xValuePropertyPicker.getState(),y:this._yValuePropertyPicker.getState(),s:this._sizeValuePropertyPicker.getState(),pl:this._pointLabelPropertyPicker.getState(),c:this._colorPropertyPicker.getState()};
};
Chart2DView.prototype.getClassName=function(){return"Chart2DView";
};
Chart2DView.prototype.reconfigureFromState=function(A){this._xValuePropertyPicker.reconfigureFromState(A.x);
this._yValuePropertyPicker.reconfigureFromState(A.y);
this._sizeValuePropertyPicker.reconfigureFromState(A.s);
this._pointLabelPropertyPicker.reconfigureFromState(A.pl);
this._colorPropertyPicker.reconfigureFromState(A.c);
};
Chart2DView.prototype.installUI=function(A){this._div=A;
this._constructUI();
this._reRender();
};
Chart2DView.prototype.uninstallUI=function(){this._xValuePropertyPicker.uninstallUI();
this._yValuePropertyPicker.uninstallUI();
this._sizeValuePropertyPicker.uninstallUI();
this._pointLabelPropertyPicker.uninstallUI();
this._colorPropertyPicker.uninstallUI();
this._div.innerHTML="";
this._div=null;
this._dom=null;
};
Chart2DView.prototype.onModeChanged=function(A){};
Chart2DView.prototype._getColorForKey=function(B){if(B in this._colorMap){return this._colorMap[B];
}else{var A=this._colorMap[B]=Chart2DView.defaultColors[this._colorMax];
this._colorMax=(this._colorMax+1)%Chart2DView.defaultColors.length;
return A;
}};
Chart2DView.prototype._constructUI=function(){var A=this;
this._div.innerHTML='<div id="results-summary-container"></div><div class="chart2d-view-controls"><table width="100%" cellspacing="10"><tr><td width="10%">X&nbsp;Values:</td><td></td></tr><tr><td width="10%">Y&nbsp;Values:</td><td></td></tr><tr><td width="10%">Size&nbsp;Values:</td><td></td></tr><tr><td width="10%">How&nbsp;to&nbsp;Label&nbsp;Points:</td><td></td></tr><tr><td width="10%">Color&nbsp;Coding:</td><td></td></tr><tr><td colspan="2"><button>Render&nbsp;Chart</button></td><td width="10%"><a href="javascript:{}" class="action">embed&nbsp;this&nbsp;chart</a></td></tr></table></div><div class="chart2d-view-canvas"></div><div class="chart2d-view-legend"></div>';
this._dom={viewSummaryContainer:this._div.childNodes[0],controlTable:this._div.childNodes[1].childNodes[0],canvasDiv:this._div.childNodes[2],legendDiv:this._div.childNodes[3],ready:false};
this._xValuePropertyPicker.installUI(this._dom.controlTable.rows[0].cells[1]);
this._yValuePropertyPicker.installUI(this._dom.controlTable.rows[1].cells[1]);
this._sizeValuePropertyPicker.installUI(this._dom.controlTable.rows[2].cells[1]);
this._pointLabelPropertyPicker.installUI(this._dom.controlTable.rows[3].cells[1]);
this._colorPropertyPicker.installUI(this._dom.controlTable.rows[4].cells[1]);
this._dom.controlTable.rows[5].cells[0].firstChild.onclick=function(){Logging.log("chart2d-view-re-render",{"state":A.getState()});
A._reRender();
};
this._dom.controlTable.rows[5].cells[1].firstChild.onclick=function(){Logging.log("chart2d-view-embed",{});
A._embed();
};
};
Chart2DView.prototype.onItemsChanged=function(){this._reRender();
};
Chart2DView.prototype.onRootItemsChanged=function(){this._setBaseRestrictionsToPropertyPickers();
};
Chart2DView.prototype._setBaseRestrictionsToPropertyPickers=function(){this._xValuePropertyPicker.setBaseQueryNode(this.collection.addBaseRestrictions());
this._yValuePropertyPicker.setBaseQueryNode(this.collection.addBaseRestrictions());
this._sizeValuePropertyPicker.setBaseQueryNode(this.collection.addBaseRestrictions());
this._pointLabelPropertyPicker.setBaseQueryNode(this.collection.addBaseRestrictions());
this._colorPropertyPicker.setBaseQueryNode(this.collection.addBaseRestrictions());
};
Chart2DView.prototype._reRender=function(){if(this._div!=null){this._dom.viewSummaryContainer.innerHTML="";
this._dom.legendDiv.innerHTML="";
this._startRenderView();
}};
Chart2DView.prototype._createJob=function(){var A={"id":null,"name":null};
this.collection.addRestrictions(A);
var B={queryNode:A,xValuePath:this._xValuePropertyPicker.getTotalPath(),yValuePath:this._yValuePropertyPicker.getTotalPath(),hasSize:this._sizeValuePropertyPicker.specified,hasColor:this._colorPropertyPicker.specified,hasPointLabel:this._pointLabelPropertyPicker.specified};
if(B.hasSize){B.sizePath=this._sizeValuePropertyPicker.getTotalPath();
}if(B.hasColor){B.colorPath=this._colorPropertyPicker.getTotalPath();
}if(B.hasPointLabel){B.pointLabelPath=this._pointLabelPropertyPicker.getTotalPath();
B.pointLabelTypeIsNative=this._pointLabelPropertyPicker.getExpectedType() in SchemaUtil.nativeTypes;
}return B;
};
Chart2DView.prototype._startRenderView=function(){ViewUtil.renderViewSummary(this.collection,this._dom.viewSummaryContainer);
var A=this;
if(!this._xValuePropertyPicker.specified||!this._yValuePropertyPicker.specified){return ;
}var B=this._createJob();
B.colorCoder=this._colorCoder;
B.colorKeys={};
var A=this;
chart2DViewQuery(B,function(G){var J=A._getAxisProperty(A._xValuePropertyPicker.getTotalPath());
var F=A._getAxisProperty(A._yValuePropertyPicker.getTotalPath());
var D=function(K){SchemaUtil.tryGetPropertyLabel(J,K);
};
var H=function(K){SchemaUtil.tryGetPropertyLabel(F,K);
};
chart2DViewPlot(A._dom.canvasDiv,G,A._colorCoder,600,D,H);
if(B.hasColorKeys){for(var E in B.colorKeys){var C=A._colorCoder.getColorForKey(E);
var I=mw.ui.createHTMLElement("div");
I.className="chart1d-view-legend-entry";
I.appendChild(SimileAjax.Graphics.createTranslucentImage("http://simile.mit.edu/painter/painter?"+["renderer=map-marker","pin=false","borderThickness=1","borderColor="+C.substr(1),"shape=circle","width=15","height=15","background="+C.substr(1)].join("&"),"middle"));
I.appendChild(document.createTextNode(E));
A._dom.legendDiv.appendChild(I);
}}});
};
Chart2DView.prototype._getAxisProperty=function(C){for(var A=C.length-1;
A>=0;
A--){var B=C[A].property;
if(B.indexOf("/measurement_unit/")!=0){return B;
}}return null;
};
Chart2DView.prototype._embed=function(){var B=this._createJob();
var C=this._getAxisProperty(this._xValuePropertyPicker.getTotalPath());
var A=this._getAxisProperty(this._yValuePropertyPicker.getTotalPath());
SchemaUtil.tryGetPropertyLabel(C,function(D){SchemaUtil.tryGetPropertyLabel(A,function(G){B.xAxisLabel=D;
B.yAxisLabel=G;
var E=document.location.href;
var H=E.indexOf("browse.html");
E=E.substr(0,H)+"chart-2d-view-embed.html?"+encodeURIComponent(JSON.stringify(B));
var F='<iframe height="600" width="100%" src="'+E+'"></iframe>';
window.prompt("HTML code to copy:",F);
});
});
};


/* map-view-querying.js */
function mapViewQuery(D,F){D.locationPath.push({property:"/location/location/geolocation",forward:true});
var O=[D.locationPath];
if(D.hasColor){O.push(D.colorPath);
}if(D.hasSize){O.push(D.sizePath);
}if(D.hasImage){O.push(D.imagePath);
}var M=extractProxyPath(O);
var A=createForwardPathIterator(M);
D.locationPath=removeProxyPath(D.locationPath,M);
var P=createForwardPathIterator(D.locationPath);
if(D.hasColor){D.colorPath=removeProxyPath(D.colorPath,M);
var I=createForwardPathIterator(D.colorPath);
}if(D.hasSize){D.sizePath=removeProxyPath(D.sizePath,M);
var E=createForwardPathIterator(D.sizePath);
}if(D.hasImage){D.imagePath=removeProxyPath(D.imagePath,M);
var L=createForwardPathIterator(D.imagePath);
}var N=D.queryNode;
N["limit"]=1000;
var K=extendQueryNodeWithPath(N,M);
if(K!=N&&D.locationPath.length>0){K["name"]=null;
}var C=extendQueryNodeWithPath(K,D.locationPath);
C["/location/geocode/latitude"]=null;
C["/location/geocode/longitude"]=null;
if(D.hasColor){var J=extendQueryNodeWithPath(K,D.colorPath);
if(!("name" in J)){J["name"]=null;
}makeQueryNodeOptionalIfEmpty(J);
}if(D.hasSize){var H=extendQueryNodeWithPath(K,D.sizePath);
makeQueryNodeOptionalIfEmpty(H);
if(!("value" in H)){H["value"]=null;
}}if(D.hasImage){var B=extendQueryNodeWithPath(K,D.imagePath);
makeQueryNodeOptionalIfEmpty(B);
if(!("/common/topic/image" in B)){B["/common/topic/image"]=[{"id":null,"limit":1,"optional":true}];
}}var G=function(V){var T=[];
var R=D.colorKeys;
D.hasColorKeys=false;
var Q=function(X){var Z=X.value;
if(typeof Z=="string"){try{Z=parseFloat(Z);
}catch(Y){}}if(typeof Z=="number"&&!isNaN(Z)){return Z;
}else{return null;
}};
var U=function(c,Z){var X={lat:null,lng:null,itemID:c.id,itemName:c.name};
P(Z,function(d){X.lat=d["/location/geocode/latitude"];
X.lng=d["/location/geocode/longitude"];
});
if(X.lat==null||X.lng==null){return ;
}if(D.hasColor){var a=null;
I(Z,function(d){a=d;
});
if(a!=null){var b=a.name;
var Y=D.colorCoder.getColorForKey(b);
R[b]=true;
D.hasColorKeys=true;
X.color=Y;
}}if(D.hasSize){E(Z,function(d){X.size=Q(d);
});
}if(D.hasImage){L(Z,function(f){if("/common/topic/image" in f){var e=f["/common/topic/image"];
if(e!=null&&e.length>0){var d=e[0];
if("id" in d&&typeof d.id=="string"){X.image="http://freebase.com/api/trans/image_thumb"+d.id+"?"+["mode=fillcrop","maxheight=100","maxwidth=100"].join("&");
}}}});
}T.push(X);
};
for(var S=0;
S<V.result.length;
S++){var W=V.result[S];
A(W,function(X){U(W,X);
});
}F(T);
};
JsonpQueue.queryOne([N],G,genericErrorHandler);
}

/* map-view.js */
function MapView(B,A){this.collection=B;
this._label=A;
this._div=null;
this._dom=null;
this._colorCoder=new DefaultColorCoder();
this._latlngPropertyPicker=new mw.ui.widgets.DimensionPathPickerWidget(true,false);
this._colorPropertyPicker=new mw.ui.widgets.DimensionPathPickerWidget(false,true);
this._sizePropertyPicker=new mw.ui.widgets.DimensionPathPickerWidget(false,true);
this._imagePropertyPicker=new mw.ui.widgets.DimensionPathPickerWidget(false,false);
this._setBaseRestrictionsToPropertyPickers();
this.collection.addListener(this);
}MapView.prototype.getLabel=function(){return(typeof this._label=="string")?("Map ("+this._label+")"):"Map";
};
MapView.prototype.dispose=function(){this._latlngPropertyPicker.dispose();
this._latlngPropertyPicker=null;
this._colorPropertyPicker.dispose();
this._colorPropertyPicker=null;
this._sizePropertyPicker.dispose();
this._sizePropertyPicker=null;
this._imagePropertyPicker.dispose();
this._imagePropertyPicker=null;
this._div=null;
this._dom=null;
this.collection.removeListener(this);
this.collection=null;
};
MapView.prototype.getState=function(){return{l:this._latlngPropertyPicker.getState(),c:this._colorPropertyPicker.getState(),s:this._sizePropertyPicker.getState(),i:this._imagePropertyPicker.getState()};
};
MapView.prototype.getClassName=function(){return"MapView";
};
MapView.prototype.reconfigureFromState=function(A){this._latlngPropertyPicker.reconfigureFromState(A.l);
this._colorPropertyPicker.reconfigureFromState(A.c);
if("s" in A){this._sizePropertyPicker.reconfigureFromState(A.s);
}if("i" in A){this._imagePropertyPicker.reconfigureFromState(A.i);
}};
MapView.prototype.installUI=function(A){this._div=A;
this._constructUI();
};
MapView.prototype.uninstallUI=function(){this._latlngPropertyPicker.uninstallUI();
this._colorPropertyPicker.uninstallUI();
this._div.innerHTML="";
this._div=null;
this._dom=null;
};
MapView.prototype.onModeChanged=function(A){};
MapView.prototype._constructUI=function(){var A=this;
this._div.innerHTML='<div id="results-summary-container"></div><div class="map-view-controls"><table width="100%" cellspacing="10"><tr><td width="10%">Location:</td><td></td></tr><tr><td width="10%">Color&nbsp;Markers&nbsp;by:</td><td></td></tr><tr><td width="10%">Size&nbsp;Markers&nbsp;by:</td><td></td></tr><tr><td width="10%">Images&nbsp;in&nbsp;Markers:</td><td></td></tr><tr><td><button>Render Map</button></td><td align="right"><a href="javascript:{}" class="action">embed this map</a></td></tr></table></div><iframe id="results-view-container" style="width: 100%; border: 1px solid #aaa; height: 500px;"></iframe><div class="map-view-legend"></div>';
this._dom={viewSummaryContainer:this._div.childNodes[0],controlTable:this._div.childNodes[1].childNodes[0],frame:this._div.childNodes[2],legendDiv:this._div.childNodes[3],ready:false};
this._latlngPropertyPicker.installUI(this._dom.controlTable.rows[0].cells[1]);
this._colorPropertyPicker.installUI(this._dom.controlTable.rows[1].cells[1]);
this._sizePropertyPicker.installUI(this._dom.controlTable.rows[2].cells[1]);
this._imagePropertyPicker.installUI(this._dom.controlTable.rows[3].cells[1]);
this._dom.controlTable.rows[4].cells[0].firstChild.onclick=function(){Logging.log("map-view-re-render",{"state":A.getState()});
A._reRender();
};
this._dom.controlTable.rows[4].cells[1].firstChild.onclick=function(){Logging.log("map-view-embed",{});
A._embed();
};
var A=this;
var B="mv"+new Date().getTime();
var C=function(){delete window[B];
A._dom.ready=true;
A._startRenderView();
};
window[B]=C;
this._dom.frame.setAttribute("src","map-view.html?callbackID="+B);
};
MapView.prototype.onItemsChanged=function(){this._reRender();
};
MapView.prototype.onRootItemsChanged=function(){this._setBaseRestrictionsToPropertyPickers();
};
MapView.prototype._setBaseRestrictionsToPropertyPickers=function(){this._latlngPropertyPicker.setBaseQueryNode(this.collection.addBaseRestrictions());
this._colorPropertyPicker.setBaseQueryNode(this.collection.addBaseRestrictions());
this._sizePropertyPicker.setBaseQueryNode(this.collection.addBaseRestrictions());
this._imagePropertyPicker.setBaseQueryNode(this.collection.addBaseRestrictions());
};
MapView.prototype._reRender=function(){if(this._div!=null){this._dom.viewSummaryContainer.innerHTML="";
this._dom.legendDiv.innerHTML="";
if(this._dom.ready){this._startRenderView();
}}};
MapView.prototype._createJob=function(){var A={"id":null,"name":null};
this.collection.addRestrictions(A);
var B={queryNode:A,locationPath:this._latlngPropertyPicker.getTotalPath(),hasColor:this._colorPropertyPicker.specified,hasSize:this._sizePropertyPicker.specified,hasImage:this._imagePropertyPicker.specified};
if(B.hasColor){B.colorPath=this._colorPropertyPicker.getTotalPath();
}if(B.hasSize){B.sizePath=this._sizePropertyPicker.getTotalPath();
}if(B.hasImage){B.imagePath=this._imagePropertyPicker.getTotalPath();
}return B;
};
MapView.prototype._startRenderView=function(){ViewUtil.renderViewSummary(this.collection,this._dom.viewSummaryContainer);
if(!this._latlngPropertyPicker.specified){try{this._dom.frame.contentWindow["clearPoints"]();
}catch(D){}return ;
}var A=this;
var C=this._createJob();
C.colorCoder=this._colorCoder;
C.colorKeys={};
var B=function(F,E){SimileAjax.WindowManager.cancelPopups();
onNewTopic(F,E);
};
mapViewQuery(C,function(H){A._dom.frame.contentWindow["mapPoints"](H,C.hasSize,C.hasImage,function(L,O,N){var M=SimileAjax.DOM.getPageCoordinates(L);
var K=SimileAjax.DOM.getPageCoordinates(A._dom.frame);
var J=K.left+M.left+Math.floor(L.offsetWidth/2);
var Q=K.top+M.top+Math.floor(L.offsetHeight/2);
var P=mw.ui.createHTMLElement("div");
P.innerHTML='<div class="item-lens-container"></div>';
renderItem(O,P,function(){SimileAjax.WindowManager.cancelPopups();
SimileAjax.Graphics.createBubbleForContentAndPoint(P,J,Q,400);
},B);
},B);
if(C.hasColorKeys){var F=C.colorKeys;
for(var G in F){var E=A._colorCoder.getColorForKey(G);
var I=mw.ui.createHTMLElement("div");
I.className="map-view-legend-entry";
I.appendChild(SimileAjax.Graphics.createTranslucentImage("http://simile.mit.edu/painter/painter?renderer=map-marker&shape=circle&width=20&height=20&pinHeight=5&background="+E.substr(1),"middle"));
I.appendChild(document.createTextNode(G));
A._dom.legendDiv.appendChild(I);
}}});
};
MapView.prototype._embed=function(){var D=this._createJob();
var A=document.location.href;
var C=A.indexOf("browse.html");
A=A.substr(0,C)+"map-view-embed.html?"+encodeURIComponent(JSON.stringify(D));
var B='<iframe height="500" width="100%" src="'+A+'"></iframe>';
window.prompt("HTML code to copy:",B);
};


/* single-topic-view.js */
(function(){var B=window.MetawebSuite;
if(!("views" in B)){B.views={};
}var A=B.views.SingleTopicView=function(C){this._uiContext=C;
this._div=null;
};
A.prototype.getLabel=function(){return"Single Topic";
};
A.prototype.dispose=function(){this._div=null;
this.collection=null;
};
A.prototype.getState=function(){return{};
};
A.prototype.getClassName=function(){return"SingleTopicView";
};
A.prototype.reconfigureFromState=function(C){};
A.prototype.installUI=function(C){this._div=C;
};
A.prototype.uninstallUI=function(){this._div.innerHTML="";
this._div=null;
};
A.prototype.onModeChanged=function(C){};
A.prototype.renderCollection=function(F){var D=F.getDefinition().getTopicID();
this._div.innerHTML='<div class="status"><img src="'+B.ui.params.baseUrl+'images/progress-running.gif" /> Retrieving information on '+D+"...</div>";
var C=B.ui.createHTMLElement("div");
var J=this;
var E=function(){if(J._div!=null){J._div.innerHTML="";
J._div.appendChild(C);
}};
var I=B.parallax.getParallaxApp(this._uiContext);
var G=function(M,L){I.browseNewTopic(M,L);
};
var H=function(M,L){I.browseNewCollection(new B.parallax.Collection(new B.parallax.PivotedCollectionDefinition(F,B.freebase.PropertyPath.createForwardPath(M),L)));
};
var K=new B.ui.renderings.TopicPageRendering(D,{onRender:E,onFocus:G,onPivot:H});
K.installUI(C);
};
})();


/* tabular-view-worker.js */
function tabularViewQuery(G,H){var D=G.queryNode;
D["limit"]=500;
var C=function(K,I){if(K.length>0){var J=extendQueryNodeWithPath(D,K);
if(I){J["value"]=null;
}else{if(!("name" in J)){J["name"]=null;
}if(!("id" in J)){J["id"]=null;
}}}};
if(G.hasRowColor){C(G.rowColorPath,G.rowColorValuesAreNative);
var B=createForwardPathIterator(G.rowColorPath);
}for(var E=0;
E<G.columnConfigs.length;
E++){var A=G.columnConfigs[E];
if("path" in A){C(A.path,A.valuesAreNative);
A.nodeIterator=createForwardPathIterator(A.path);
}}var F=function(M){var K=[];
var J=G.rowColorKeys;
G.hasRowColorKeys=false;
var L=function(P){var V={cells:[]};
if(G.hasRowColor){var O=null;
B(P,function(X){O=X;
});
if(O!=null){var T="name" in O?O.name:O.value;
var R=G.colorCoder.getColorForKey(T);
J[T]=true;
G.hasRowColorKeys=true;
V.color=R;
}}for(var S=0;
S<G.columnConfigs.length;
S++){var W=G.columnConfigs[S];
var U={values:[]};
if("nodeIterator" in W){var Q=function(X){if("name" in X){U.values.push({name:X.name,id:X.id});
}else{U.values.push({value:X.value});
}};
W.nodeIterator(P,Q);
}V.cells.push(U);
}K.push(V);
};
for(var I=0;
I<M.result.length;
I++){var N=M.result[I];
L(N);
}H(K);
};
JsonpQueue.queryOne([D],F,genericErrorHandler);
}function tabularViewSort(P,J,H,E){var B=function(R,Q){return R.sortKey.localeCompare(Q.sortKey);
};
var G=function(R,Q){return R.sortKey-Q.sortKey;
};
var D;
var N;
var I;
if(E in SchemaUtil.nativeTypes){switch(E){case"/type/int":case"/type/float":D=function(Q){if(Q!=null){try{var S=parseFloat(Q.value);
if(!isNaN(S)){return S;
}}catch(R){}}return null;
};
N=Number.NEGATIVE_INFINITY;
I=G;
break;
case"/type/boolean":D=function(Q){if(Q!=null){if("value" in Q){if(typeof Q.value=="boolean"){return Q.value?1:0;
}else{var R=Q.value.toString().toLowerCase();
if(R=="true"){return 1;
}else{if(R=="false"){return 0;
}}}}}return null;
};
N=-1;
I=G;
break;
default:D=function(Q){if(Q!=null){if("value" in Q){var R=Q.value.toString().toLowerCase();
return R;
}}return null;
};
N="";
I=B;
}}else{D=function(Q){if(Q!=null){if("name" in Q){var R=Q.name.toLowerCase();
return R;
}}return null;
};
N="";
I=B;
}for(var F=0;
F<P.length;
F++){var O=P[F];
var M=O.cells[J];
var L=M.values;
var C=null;
for(var K=0;
C==null&&K<L.length;
K++){C=D(L[K]);
}O.sortKey=(C==null)?N:C;
}var A=H?I:function(R,Q){return I(Q,R);
};
P.sort(A);
}function tabularViewRender(R,J,M,Y){R.innerHTML="";
if(M.length==0){return ;
}var X=mw.ui.createHTMLElement("table");
X.className="tabular-view-table";
X.setAttribute("cellspacing","0");
X.setAttribute("width","100%");
R.appendChild(X);
var a=J.columnConfigs.length+(Y.editable?1:0);
var E=X.insertRow(0);
var N=X.insertRow(1);
var W=N.insertCell(0);
W.setAttribute("colspan",a);
W.className="tabular-view-header-editing-container";
N.style.display="none";
var U=function(){var c=E.cells;
for(var d=0;
d<c.length;
d++){c[d].className="tabular-view-header-cell";
}N.style.display="none";
};
var L=function(d,j){var i=E.insertCell(j);
i.className="tabular-view-header-cell";
if(j>0&&Y.editable){var e=SimileAjax.Graphics.createTranslucentImage(mw.views.params.baseUrl+"images/close-button.png","middle");
e.className="tabular-view-header-remove-button";
e.onclick=function(){Y.onRemoveColumn(e,j);
};
i.appendChild(e);
var g=mw.ui.createHTMLElement("a");
g.className="action tabular-view-header-edit-button";
g.href="javascript:{}";
g.innerHTML="edit";
g.onclick=function(){U();
N.style.display="";
i.className="tabular-view-header-cell tabular-view-header-editing";
Y.onEditColumn(g,j,W,U);
};
i.appendChild(g);
}var h=mw.ui.createHTMLElement("span");
h.className="tabular-view-header-label";
h.appendChild(document.createTextNode("label" in d?d.label:"?"));
if(j==J.sortColumnIndex){var f=SimileAjax.Graphics.createTranslucentImage(mw.views.params.baseUrl+(J.sortColumnAscending?"images/up-arrow.png":"images/down-arrow.png"),"middle");
h.appendChild(f);
}h.onclick=function(){Y.onSortColumn(j);
};
i.appendChild(h);
};
for(var Z=0;
Z<J.columnConfigs.length;
Z++){var b=J.columnConfigs[Z];
L(b,Z);
}if(Y.editable){var I=E.insertCell(J.columnConfigs.length);
I.className="tabular-view-header-cell";
I.setAttribute("width","1%");
var A=mw.ui.createHTMLElement("a");
A.className="action";
A.href="javascript:{}";
A.innerHTML="add";
A.onclick=function(){U();
N.style.display="";
I.className="tabular-view-header-cell tabular-view-header-editing";
Y.onAddColumn(A,W,U);
};
I.appendChild(A);
}var T=function(d){var c=mw.ui.createHTMLElement("a");
c.href="http://www.freebase.com/view"+d.id;
c.appendChild(document.createTextNode(d.name));
$(c).click(function(e){Logging.log("tabular-view-to-topic",{"id":d.id});
Y.onFocus(d.id,d.name);
e.preventDefault();
});
return c;
};
var C=function(c){if("name" in c){return T(c);
}else{return document.createTextNode(c.value);
}};
for(var S=0;
S<M.length;
S++){var H=M[S];
var B=X.insertRow(S+2);
if("color" in H){B.style.backgroundColor=H.color;
}var G=H.cells;
for(var Z=0;
Z<G.length;
Z++){var D=G[Z];
var K=B.insertCell(Z);
K.className="tabular-view-data-cell";
var F=D.values;
if(F.length==0){K.innerHTML="&nbsp;";
}else{if(F.length==1){K.appendChild(C(F[0]));
}else{var P=mw.ui.createHTMLElement("ol");
K.appendChild(P);
for(var O=0;
O<F.length;
O++){var V=F[O];
var Q=mw.ui.createHTMLElement("li");
P.appendChild(Q);
Q.appendChild(C(V));
}}}}}}

/* tabular-view.js */
function TabularView(B,A){this.collection=B;
this._label=A;
this._div=null;
this._dom=null;
this._colorCoder=new DefaultColorCoder();
this._sortColumnIndex=0;
this._sortColumnAscending=true;
this._columnRecords=[this._constructColumnRecord(true)];
this._rowColorPropertyPicker=new mw.ui.widgets.DimensionPathPickerWidget(false,true,false);
this._editing=false;
this._editingElmt=null;
this._editingIndex=-1;
this._editingColumnRecord=null;
this._setBaseRestrictionsToPropertyPickers();
this.collection.addListener(this);
}TabularView.prototype.getLabel=function(){return(typeof this._label=="string")?("Table ("+this._label+")"):"Table";
};
TabularView.prototype.dispose=function(){this._disposeColumnRecords();
this._rowColorPropertyPicker.dispose();
this._rowColorPropertyPicker=null;
this._div=null;
this._dom=null;
this.collection.removeListener(this);
this.collection=null;
};
TabularView.prototype.getState=function(){var C=[];
for(var A=0;
A<this._columnRecords.length;
A++){var B=this._columnRecords[A];
C.push({p:B.propertyPicker.getState()});
}return{cols:C,sort:this._sortColumnIndex,asc:this._sortColumnAscending,c:this._rowColorPropertyPicker.getState()};
};
TabularView.prototype.getClassName=function(){return"TabularView";
};
TabularView.prototype.reconfigureFromState=function(C){this._uninstallColumnUI();
this._disposeColumnRecords();
this._columnRecords=[];
var B=C.cols;
for(var A=0;
A<B.length;
A++){var E=B[A];
var D=this._constructColumnRecord();
this._columnRecords.push(D);
D.propertyPicker.reconfigureFromState(E.p);
}this._rowColorPropertyPicker.reconfigureFromState(C.c);
};
TabularView.prototype._disposeColumnRecords=function(){for(var A=0;
A<this._columnRecords.length;
A++){var B=this._columnRecords[A];
B.propertyPicker.dispose();
B.propertyPicker=null;
}this._columnRecords=null;
};
TabularView.prototype.installUI=function(A){this._div=A;
this._constructUI();
this._reRender();
};
TabularView.prototype.uninstallUI=function(){this._uninstallColumnUI();
this._rowColorPropertyPicker.uninstallUI();
this._disposeEditingUI();
this._div.innerHTML="";
this._div=null;
this._dom=null;
};
TabularView.prototype._disposeEditingUI=function(){if(this._editing){this._editingColumnRecord.propertyPicker.uninstallUI();
this._editingColumnRecord.propertyPicker.dispose();
this._editingColumnRecord=null;
this._editingElmt.innerHTML="";
this._editingElmt=null;
this._editingIndex=-1;
this._editing=false;
}};
TabularView.prototype._uninstallColumnUI=function(){if(this._div!=null){for(var A=0;
A<this._columnRecords.length;
A++){var B=this._columnRecords[A];
B.propertyPicker.uninstallUI();
}}};
TabularView.prototype._constructColumnRecord=function(B){var A=new mw.ui.widgets.DimensionPathPickerWidget(B,true,false);
A.setBaseQueryNode(this.collection.addBaseRestrictions());
return{propertyPicker:A};
};
TabularView.prototype.onModeChanged=function(A){};
TabularView.prototype._constructUI=function(){var A=this;
this._div.innerHTML='<div id="results-summary-container"></div><div class="tabular-view-controls"><table cellspacing="10"><tr><td width="10%">Row&nbsp;Color&nbsp;Coding:</td><td></td></tr><tr><td colspan="2"><button>Render&nbsp;Table</button></td><td width="10%"><a href="javascript:{}" class="action">embed&nbsp;this&nbsp;table</a></td></tr></table></div><div class="tabular-view-legend"></div><div class="tabular-view-canvas"></div>';
this._dom={viewSummaryContainer:this._div.childNodes[0],controlTable:this._div.childNodes[1].childNodes[0],legendDiv:this._div.childNodes[2],canvasDiv:this._div.childNodes[3]};
this._rowColorPropertyPicker.installUI(this._dom.controlTable.rows[0].cells[1]);
this._dom.controlTable.rows[1].cells[0].firstChild.onclick=function(){Logging.log("tabular-view-re-render",{"state":A.getState()});
A._reRender();
};
this._dom.controlTable.rows[1].cells[1].firstChild.onclick=function(){Logging.log("tabular-view-embed",{});
A._embed();
};
};
TabularView.prototype.onItemsChanged=function(){this._reRender();
};
TabularView.prototype.onRootItemsChanged=function(){this._setBaseRestrictionsToPropertyPickers();
};
TabularView.prototype._setBaseRestrictionsToPropertyPickers=function(){for(var A=0;
A<this._columnRecords.length;
A++){var B=this._columnRecords[A];
B.propertyPicker.setBaseQueryNode(this.collection.addBaseRestrictions());
}this._rowColorPropertyPicker.setBaseQueryNode(this.collection.addBaseRestrictions());
};
TabularView.prototype._reRender=function(){if(this._div!=null){this._dom.viewSummaryContainer.innerHTML="";
this._dom.legendDiv.innerHTML="";
this._startRenderView();
}};
TabularView.prototype._createJob=function(){var A={"id":null,"name":null};
this.collection.addRestrictions(A);
var D={queryNode:A,columnConfigs:[],sortColumnIndex:this._sortColumnIndex,sortColumnAscending:this._sortColumnAscending,hasRowColor:this._rowColorPropertyPicker.specified};
if(D.hasRowColor){D.rowColorPath=this._rowColorPropertyPicker.getTotalPath();
D.rowColorValuesAreNative=true;
if(D.rowColorPath.length==0){D.rowColorValuesAreNative=false;
}else{var E=D.rowColorPath[D.rowColorPath.length-1].property;
if(E in SchemaUtil.propertyRecords){var F=SchemaUtil.propertyRecords[E];
if(!(F.expectedType in SchemaUtil.nativeTypes)){D.rowColorValuesAreNative=false;
}}}}var B=function(I){var G={valuesAreNative:false,valueType:""};
if(I.propertyPicker.specified){G.path=I.propertyPicker.getTotalPath();
if(G.path.length==0){G.label="Topic";
G.valuesAreNative=false;
}else{var H=G.path[G.path.length-1].property;
G.label=H;
if(H in SchemaUtil.propertyRecords){var J=SchemaUtil.propertyRecords[H];
G.label=J.name;
G.valueType=J.expectedType;
if(J.expectedType in SchemaUtil.nativeTypes){G.valuesAreNative=true;
}}}}return G;
};
for(var C=0;
C<this._columnRecords.length;
C++){D.columnConfigs.push(B(this._columnRecords[C]));
}return D;
};
TabularView.prototype._startRenderView=function(){ViewUtil.renderViewSummary(this.collection,this._dom.viewSummaryContainer);
var A=this;
var B=this._createJob();
B.colorCoder=this._colorCoder;
B.rowColorKeys={};
var A=this;
tabularViewQuery(B,function(K){if(A._sortColumnIndex>=0){tabularViewSort(K,A._sortColumnIndex,A._sortColumnAscending);
}var J=function(N,M,L){A._startEditing(A._columnRecords.length,A._constructColumnRecord(false),M,L);
};
var H=function(L,M){A._columnRecords.splice(M,1);
A._startRenderView();
};
var G=function(N,O,M,L){var P=A._constructColumnRecord(false);
P.propertyPicker.reconfigureFromState(A._columnRecords[O].propertyPicker.getState());
A._startEditing(O,P,M,L);
};
var F=function(L){if(L==A._sortColumnIndex){A._sortColumnAscending=!A._sortColumnAscending;
}else{A._sortColumnIndex=L;
A._sortColumnAscending=true;
}B.sortColumnIndex=A._sortColumnIndex;
B.sortColumnAscending=A._sortColumnAscending;
tabularViewSort(K,A._sortColumnIndex,A._sortColumnAscending,B.columnConfigs[A._sortColumnIndex].valueType);
D();
};
var D=function(){tabularViewRender(A._dom.canvasDiv,B,K,{editable:true,onAddColumn:J,onRemoveColumn:H,onEditColumn:G,onFocus:onNewTopic,onSortColumn:F});
};
D();
if(B.hasRowColorKeys){for(var I in B.rowColorKeys){var E=A._colorCoder.getColorForKey(I);
var C=mw.ui.createHTMLElement("div");
C.className="tabular-view-legend-entry";
C.appendChild(SimileAjax.Graphics.createTranslucentImage("http://simile.mit.edu/painter/painter?"+["renderer=map-marker","pin=false","borderThickness=1","borderColor="+E.substr(1),"shape=circle","width=15","height=15","background="+E.substr(1)].join("&"),"middle"));
C.appendChild(document.createTextNode(I));
A._dom.legendDiv.appendChild(C);
}}});
};
TabularView.prototype._embed=function(){var D=this._createJob();
var A=document.location.href;
var C=A.indexOf("browse.html");
A=A.substr(0,C)+"tabular-view-embed.html?"+encodeURIComponent(JSON.stringify(D));
var B='<iframe height="600" width="100%" src="'+A+'"></iframe>';
window.prompt("HTML code to copy:",B);
};
TabularView.prototype._startEditing=function(D,H,C,G){this._disposeEditingUI();
this._editingElmt=C;
this._editingIndex=D;
this._editingColumnRecord=H;
this._editing=true;
C.innerHTML="";
var F=mw.ui.createHTMLElement("div");
F.className="tabular-view-editing-settings";
C.appendChild(F);
this._editingColumnRecord.propertyPicker.installUI(F);
var A=mw.ui.createHTMLElement("div");
A.className="tabular-view-editing-controls";
A.innerHTML="<button>Done</button> <button>Cancel</button>";
C.appendChild(A);
var B=this;
var E=A.getElementsByTagName("button");
E[0].onclick=function(){B._columnRecords[D]=H;
B._disposeEditingUI();
B._startRenderView();
};
E[1].onclick=function(){B._disposeEditingUI();
G();
};
};


/* thumbnail-view.js */
(function(){var B=window.MetawebSuite;
if(!("views" in B)){B.views={};
}var A=B.views.ThumbnailView=function(C){this._uiContext=C;
this._div=null;
this._dom=null;
};
A.prototype.getLabel=function(){return"Thumbnails";
};
A.prototype.dispose=function(){this._uiContext=null;
this._div=null;
this._dom=null;
};
A.prototype.getState=function(){return{};
};
A.prototype.getClassName=function(){return"ThumbnailView";
};
A.prototype.reconfigureFromState=function(C){};
A.prototype.installUI=function(E){this._div=E;
this._div.innerHTML='<div id="thumbnail-view-controls">&raquo; embed these topics <a href="javascript:{}" class="action">as thumbnails</a> &bull; <a href="javascript:{}" class="action">as tiles</a></div><div id="results-view-container"></div>';
this._dom={controlDiv:this._div.childNodes[0],viewContainer:this._div.childNodes[1]};
var C=this;
var D=this._dom.controlDiv.getElementsByTagName("a");
D[0].onclick=function(){Logging.log("thumbnail-view-embed-thumbnails");
C._embedThumbnails();
};
D[1].onclick=function(){Logging.log("thumbnail-view-embed-tiles");
C._embedTiles();
};
};
A.prototype.uninstallUI=function(){this._div.innerHTML="";
this._div=null;
this._dom=null;
};
A.prototype.onModeChanged=function(C){};
A.prototype.renderCollection=function(E){this._dom.viewContainer.innerHTML="";
var D=this;
var C={"id":null,"limit":100};
E.addRestrictions(C,{"id":null,"name":null});
B.freebase.mql.read([C],function(F){D._renderView(E,F.result);
},B.system.exception);
};
A.prototype.renderExpression=function(D){this._dom.viewContainer.innerHTML="";
var C=this;
D.evaluate({},function(E){C._internalRenderView(E.values,function(){});
},B.system.exception);
};
A.prototype._renderView=function(I,D){var H=I.getDefinition();
var F=function(){};
if(H.hasBaseCollection()){var C;
var E=H.getBaseNodeIterator();
var G=function(K){var J=B.ui.createHTMLElement("a");
J.href="javascript:{}";
J.innerHTML=K.name;
J.onclick=function(){onNewTopic(K.id,K.name);
};
return J;
};
F=function(J,K){var M=[];
E(K,function(N){M.push(N);
});
for(var L=0;
L<Math.min(3,M.length);
L++){if(L>0){J.appendChild(document.createTextNode(", "));
}J.appendChild(G(M[L]));
}if(M.length>3){J.appendChild(document.createTextNode(" ..."));
}J.appendChild(document.createTextNode(" \u2192"));
};
}this._internalRenderView(D,F);
};
A.prototype._internalRenderView=function(G,F){this._dom.viewContainer.innerHTML="";
var K=B.parallax.getParallaxApp(this._uiContext);
var J=function(N,M){K.browseNewTopic(N,M);
};
for(var H=0;
H<G.length;
H++){var E=G[H];
var D=E.id;
var C=B.ui.createHTMLElement("div");
C.className="item-lens-container";
C.innerHTML='<div class="item-lens-base-results"></div><div class="item-lens-inner-container">Rendering '+D+"</div>";
this._dom.viewContainer.appendChild(C);
F(C.childNodes[0],E);
try{var L=new B.ui.renderings.TopicThumbnailRendering(D,{onFocus:J,onThumbnail:B.ui.showLightboxForImage});
L.installUI(C.childNodes[1]);
}catch(I){C.childNodes[1].innerHTML=I;
}}};
A.prototype._embedThumbnails=function(){this._embed("thumbnail-view-embed-thumbnails.html",80);
};
A.prototype._embedTiles=function(){this._embed("thumbnail-view-embed-tiles.html",50);
};
A.prototype._embed=function(G,D){var C={"id":null,"limit":100};
this.collection.addRestrictions(C,{"id":null,"name":null});
var E=document.location.href;
var H=E.indexOf("browse.html");
E=E.substr(0,H)+G+"?thumbsize="+D+"&query="+encodeURIComponent(JSON.stringify(C));
var F='<iframe height="600" width="100%" src="'+E+'"></iframe>';
window.prompt("HTML code to copy:",F);
};
})();


/* timeline-view-worker.js */
function timelineViewQuery(C,D){var P=[C.startPath];
if(C.hasEnd){P.push(C.endPath);
}if(C.hasLabel){P.push(C.labelPath);
}if(C.hasColor){P.push(C.colorPath);
}var N=extractProxyPath(P);
var B=createForwardPathIterator(N);
C.startPath=removeProxyPath(C.startPath,N);
var A=createForwardPathIterator(C.startPath);
if(C.hasEnd){C.endPath=removeProxyPath(C.endPath,N);
var I=createForwardPathIterator(C.endPath);
}if(C.hasLabel){C.labelPath=removeProxyPath(C.labelPath,N);
var G=createForwardPathIterator(C.labelPath);
}if(C.hasColor){C.colorPath=removeProxyPath(C.colorPath,N);
var J=createForwardPathIterator(C.colorPath);
}var O=C.queryNode;
O["limit"]=1000;
var M=extendQueryNodeWithPath(O,N);
if(M!=O&&C.startPath.length>0){M["name"]=null;
}var L=extendQueryNodeWithPath(M,C.startPath);
if(C.hasEnd){var H=extendQueryNodeWithPath(M,C.endPath);
makeQueryNodeOptionalIfEmpty(H);
if(!("value" in H)){H["value"]=null;
}}if(C.hasLabel){var E=extendQueryNodeWithPath(M,C.labelPath);
if(!("name" in E)){E["name"]=null;
}if(!("id" in E)){E["id"]=null;
}makeQueryNodeOptionalIfEmpty(E);
}if(C.hasColor){var K=extendQueryNodeWithPath(M,C.colorPath);
if(!("name" in K)){K["name"]=null;
}makeQueryNodeOptionalIfEmpty(K);
}var F=function(V){var S=[];
var Q=C.colorKeys;
C.hasColorKeys=false;
var T=function(X){try{return SimileAjax.DateTime.parseIso8601DateTime(X.value);
}catch(Y){}return null;
};
var U=function(c,Z){var X={start:null,end:null,itemID:c.id,itemName:c.name};
A(Z,function(d){X.start=T(d);
});
if(X.start==null){return ;
}if(C.hasEnd){I(Z,function(d){X.end=T(d);
});
}if(C.hasLabel){G(Z,function(d){X.itemID=d.id;
X.itemName=d.name;
});
}if(C.hasColor){var a=null;
J(Z,function(d){a=d;
});
if(a!=null){var b=a.name;
var Y=C.colorCoder.getColorForKey(b);
Q[b]=true;
C.hasColorKeys=true;
X.color=Y;
}}S.push(X);
};
for(var R=0;
R<V.result.length;
R++){var W=V.result[R];
B(W,function(X){U(W,X);
});
}D(S);
};
JsonpQueue.queryOne([O],F,genericErrorHandler);
}function timelineViewFillEventSource(E,C){var B=[];
var D=function(F){var H="color" in F?F.color:null;
var G=new Timeline.DefaultEventSource.Event(F.itemID,F.start,"end" in F?F.end:null,null,null,!("end" in F),F.itemName,"",null,null,null,H,H,null);
G._itemID=F.itemID;
B.push(G);
};
for(var A=0;
A<C.length;
A++){D(C[A]);
}E.addMany(B);
}function timelineViewConstructTimeline(D,B,L){var A=100;
var P=100;
var K=D.getEarliestDate();
var H=D.getLatestDate();
var N=H.getTime()-K.getTime();
var G=D.getCount();
if(N>0&&G>1){var C=G/N;
var F=Timeline.DateTime.MILLENNIUM;
while(F>0){var I=Timeline.DateTime.gregorianUnitLengths[F];
var E=C*I/A;
if(E<0.1){break;
}F--;
}}else{F=Timeline.DateTime.YEAR;
}bottomIntervalUnit=F+1;
var J=Timeline.ClassicTheme.create();
J.event.bubble.width=400;
var O=[Timeline.createBandInfo({width:"90%",intervalUnit:F,intervalPixels:A,eventSource:D,date:H,theme:J}),Timeline.createBandInfo({width:"10%",intervalUnit:bottomIntervalUnit,intervalPixels:P,eventSource:D,overview:true,date:H,theme:J})];
O[1].syncWith=0;
O[1].highlight=true;
var M=Timeline.create(B,O,Timeline.HORIZONTAL);
M.getBand(0).getEventPainter()._showBubble=M.getBand(1).getEventPainter()._showBubble=function(Q,U,R){var T=mw.ui.createHTMLElement("div");
T.innerHTML='<div class="timeline-view-bubble-content"></div>';
var S=this._params.theme.event.bubble.width;
renderItem(R._itemID,T.firstChild,function(){SimileAjax.WindowManager.cancelPopups();
SimileAjax.Graphics.createBubbleForContentAndPoint(T,Q,U,S);
},function(W,V){L(W,V);
});
};
return M;
}

/* timeline-view.js */
function TimelineView(B,A){this.collection=B;
this._label=A;
this._div=null;
this._dom=null;
this._timeline=null;
this._eventSource=null;
this._colorCoder=new DefaultColorCoder();
this._startPropertyPicker=new mw.ui.widgets.DimensionPathPickerWidget(false,true);
this._endPropertyPicker=new mw.ui.widgets.DimensionPathPickerWidget(false,true);
this._labelPropertyPicker=new mw.ui.widgets.DimensionPathPickerWidget(false,true);
this._colorPropertyPicker=new mw.ui.widgets.DimensionPathPickerWidget(false,true);
this._setBaseRestrictionsToPropertyPickers();
this.collection.addListener(this);
}TimelineView.prototype.getLabel=function(){return(typeof this._label=="string")?("Timeline ("+this._label+")"):"Timeline";
};
TimelineView.prototype.dispose=function(){this._startPropertyPicker.dispose();
this._startPropertyPicker=null;
this._endPropertyPicker.dispose();
this._endPropertyPicker=null;
this._colorPropertyPicker.dispose();
this._colorPropertyPicker=null;
this._div=null;
this._dom=null;
this.collection.removeListener(this);
this.collection=null;
};
TimelineView.prototype.getState=function(){return{s:this._startPropertyPicker.getState(),e:this._endPropertyPicker.getState(),l:this._labelPropertyPicker.getState(),c:this._colorPropertyPicker.getState()};
};
TimelineView.prototype.getClassName=function(){return"TimelineView";
};
TimelineView.prototype.reconfigureFromState=function(A){this._startPropertyPicker.reconfigureFromState(A.s);
this._endPropertyPicker.reconfigureFromState(A.e);
if("l" in A){this._labelPropertyPicker.reconfigureFromState(A.l);
}this._colorPropertyPicker.reconfigureFromState(A.c);
};
TimelineView.prototype.installUI=function(A){this._div=A;
this._constructUI();
};
TimelineView.prototype.uninstallUI=function(){if(this._timeline!=null){this._timeline.dispose();
this._timeline=null;
}this._startPropertyPicker.uninstallUI();
this._endPropertyPicker.uninstallUI();
this._labelPropertyPicker.uninstallUI();
this._colorPropertyPicker.uninstallUI();
this._div.innerHTML="";
this._div=null;
this._dom=null;
};
TimelineView.prototype.onModeChanged=function(A){};
TimelineView.prototype._constructUI=function(){var A=this;
this._div.innerHTML='<div id="results-summary-container"></div><div class="timeline-view-controls"><table width="100%" cellspacing="10"><tr><td width="10%">Start:</td><td colspan="2"></td></tr><tr><td width="10%">End:</td><td colspan="2"></td></tr><tr><td width="10%">Label:</td><td colspan="2"></td></tr><tr><td width="10%">Color:</td><td colspan="2"></td></tr><tr><td colspan="2"><button>Render&nbsp;Timeline</button></td><td align="right" width="10%"><a href="javascript:{}" class="action">embed&nbsp;this&nbsp;timeline</a></td></tr></table></div><div class="timeline-view-container"></div><div class="timeline-view-legend"></div>';
this._dom={viewSummaryContainer:this._div.childNodes[0],controlTable:this._div.childNodes[1].childNodes[0],timelineDiv:this._div.childNodes[2],legendDiv:this._div.childNodes[3],ready:false};
this._startPropertyPicker.installUI(this._dom.controlTable.rows[0].cells[1]);
this._endPropertyPicker.installUI(this._dom.controlTable.rows[1].cells[1]);
this._labelPropertyPicker.installUI(this._dom.controlTable.rows[2].cells[1]);
this._colorPropertyPicker.installUI(this._dom.controlTable.rows[3].cells[1]);
this._dom.controlTable.rows[4].cells[0].firstChild.onclick=function(){Logging.log("timeline-view-re-render",{"state":A.getState()});
A._reRender();
};
this._dom.controlTable.rows[4].cells[1].firstChild.onclick=function(){Logging.log("timeline-view-embed",{});
A._embed();
};
if("Timeline" in window){this._dom.ready=true;
this._startRenderView();
}else{var A=this;
SimileAjax_onLoad=function(){A._dom.ready=true;
A._startRenderView();
};
SimileAjax.includeJavascriptFiles(document,"",["http://static.simile.mit.edu/timeline/api-2.0/timeline-api.js"]);
}};
TimelineView.prototype.onItemsChanged=function(){this._reRender();
};
TimelineView.prototype.onRootItemsChanged=function(){this._setBaseRestrictionsToPropertyPickers();
};
TimelineView.prototype._setBaseRestrictionsToPropertyPickers=function(){this._startPropertyPicker.setBaseQueryNode(this.collection.addBaseRestrictions());
this._endPropertyPicker.setBaseQueryNode(this.collection.addBaseRestrictions());
this._labelPropertyPicker.setBaseQueryNode(this.collection.addBaseRestrictions());
this._colorPropertyPicker.setBaseQueryNode(this.collection.addBaseRestrictions());
};
TimelineView.prototype._reRender=function(){if(this._div!=null){this._dom.viewSummaryContainer.innerHTML="";
this._dom.legendDiv.innerHTML="";
if(this._dom.ready){this._startRenderView();
}}};
TimelineView.prototype._createJob=function(){var A={"id":null,"name":null};
this.collection.addRestrictions(A);
var B={queryNode:A,startPath:this._startPropertyPicker.getTotalPath(),hasEnd:this._endPropertyPicker.specified,hasColor:this._colorPropertyPicker.specified,hasLabel:this._labelPropertyPicker.specified};
if(B.hasEnd){B.endPath=this._endPropertyPicker.getTotalPath();
}if(B.hasLabel){B.labelPath=this._labelPropertyPicker.getTotalPath();
}if(B.hasColor){B.colorPath=this._colorPropertyPicker.getTotalPath();
}return B;
};
TimelineView.prototype._startRenderView=function(){var A=this;
ViewUtil.renderViewSummary(this.collection,this._dom.viewSummaryContainer);
if(this._eventSource!=null){this._eventSource.clear();
}if(!this._startPropertyPicker.specified){return ;
}var B=this._createJob();
B.colorCoder=this._colorCoder;
B.colorKeys={};
var A=this;
timelineViewQuery(B,function(E){A._plotEvents(E);
if(B.hasColorKeys){for(var D in B.colorKeys){var C=A._colorCoder.getColorForKey(D);
var F=mw.ui.createHTMLElement("div");
F.className="timeline-view-legend-entry";
F.appendChild(SimileAjax.Graphics.createTranslucentImage("http://simile.mit.edu/painter/painter?renderer=map-marker&shape=circle&width=20&height=20&pin=false&background="+C.substr(1),"middle"));
F.appendChild(document.createTextNode(D));
A._dom.legendDiv.appendChild(F);
}}});
};
TimelineView.prototype._plotEvents=function(D){if(this._eventSource==null){this._eventSource=new Timeline.DefaultEventSource();
}timelineViewFillEventSource(this._eventSource,D);
if(this._timeline==null){this._dom.timelineDiv.style.height="500px";
this._timeline=timelineViewConstructTimeline(this._eventSource,this._dom.timelineDiv,function(G,F){onNewTopic(G,F);
});
}else{var E=this._timeline.getBand(0);
var C=E.getCenterVisibleDate();
var A=this._eventSource.getEarliestDate();
var B=this._eventSource.getLatestDate();
if(A!=null&&C<A){E.scrollToCenter(A);
}else{if(B!=null&&C>B){E.scrollToCenter(B);
}}}};
TimelineView.prototype._embed=function(){var D=this._createJob();
var A=document.location.href;
var C=A.indexOf("browse.html");
A=A.substr(0,C)+"timeline-view-embed.html?"+encodeURIComponent(JSON.stringify(D));
var B='<iframe height="500" width="100%" src="'+A+'"></iframe>';
window.prompt("HTML code to copy:",B);
};


/* view-util.js */
var ViewUtil={};
ViewUtil.renderViewSummary=function(D,E){var B={};
E.innerHTML='<div class="status"><img src="'+mw.ui.params.baseUrl+'images/progress-running.gif" /> Retrieving information...</div>';
var A=function(F){B.allCount=F;
D.getRestrictedItemCount(C,genericErrorHandler);
};
var C=function(F){B.restrictedCount=F;
ViewUtil._tryRenderSummary(D,E,B.restrictedCount,B.allCount);
};
D.getAllItemCount(A,genericErrorHandler);
};
ViewUtil._tryRenderSummary=function(C,D,A,B){ViewUtil._renderSummary(D,null,A,B);
mw.freebase.schemas.tryGetTypeLabel(C.getDefinition(),function(E){ViewUtil._renderSummary(D,E,A,B);
});
};
ViewUtil._renderSummary=function(E,A,C,D){var B="";
if(A!=null){B+='<span class="results-summary-type">'+A+"</span>: ";
}if(C==D){B+='<span class="results-summary-count">'+D+" topics</span>";
}else{B+='<span class="results-summary-count">'+C+" topics</span> filtered from <span results-summary-original-count>"+D+"</span> originally";
}E.innerHTML=B;
};


/* terminal.js */
window.MetawebSuite.system.onFinishLoadingPackage("metaweb-suite-views");


/* parallax-package.js */
(function() {
    mw.system.onStartLoadingNativePackage(
        "parallax",
        [   "app.js",
            "util/logging.js",
            "facets/list-facet.js",
            "facets/text-search-facet.js",
            "trail-point.js",
            
            "facet-panel.js",
            "history-panel.js",
            "view-panel.js",
            "pivot-panel.js",
            "collection-bound-view-container.js",
            
            "terminal.js"
        ],
        [
            "common.css",
            "browse.css",
            "history.css",
            "pivots.css",
            "facets.css"
        ]
    );
})();


/* parallax-bundle.js */


/* app.js */
(function(){var B=window.MetawebSuite;
if(!("parallax" in B)){B.parallax={};
}B.parallax.getParallaxApp=function(C){return C.getSetting("parallax-app");
};
var A=B.parallax.ParallaxApp=function(){this._componentMap={};
this._listeners=new B.core.ListenerQueue();
this._trailPoints=[];
this._trailPointIndex=-1;
this._uiContext=new B.ui.UIContext();
this._uiContext.putSetting("parallax-app",this);
};
A.prototype.addListener=function(C){this._listeners.add(C);
};
A.prototype.removeListener=function(C){this._listeners.remove(C);
};
A.prototype.getTrailPoint=function(C){return C>=0&&C<this._trailPoints.length?this._trailPoints[C]:null;
};
A.prototype.getTrailPointCount=function(){return this._trailPoints.length;
};
A.prototype.getCurrentTrailPoint=function(){return this._trailPointIndex>=0?this._trailPoints[this._trailPointIndex]:null;
};
A.prototype.getCurrentTrailPointIndex=function(){return this._trailPointIndex;
};
A.prototype.getComponent=function(C){return this._componentMap[C];
};
A.prototype.setComponent=function(E,D){if(E in this._componentMap){try{this._componentMap[E].dispose();
}catch(C){B.system.exception(C);
}}this._componentMap[E]=D;
};
A.prototype.disposeComponent=function(D){if(D in this._componentMap){try{this._componentMap[D].dispose();
}catch(C){B.system.exception(C);
}delete this._componentMap[D];
}};
A.prototype.initializeFromURL=function(){var F=B.system.parseURLParameters(document.location.href);
if("state" in F){var D=null;
try{D=window.rison.decode(F["state"]);
}catch(H){}if(D!=null){Logging.log("browse-old-state",D);
this._playback(D);
return ;
}}if("id" in F){var E=F["id"];
var J="label" in F?F["label"]:E;
Logging.log("browse-new-state",{"id":E});
this.browseNewTopic(E,J);
}else{if("ids" in F){var C=F["ids"].split(";");
var I="names" in F?F["names"].split(";"):[];
Logging.log("browse-new-state",{"ids":C,"names":I});
this.browseNewCollection(new B.parallax.Collection(new B.parallax.MultipleTopicCollectionDefinition(C,I)));
}else{var G=F["type"];
var K="search" in F?F["search"]:null;
Logging.log("browse-new-state",{"typeID":G,"search":K});
this.browseNewCollection(new B.parallax.Collection(new B.parallax.RootTypeCollectionDefinition(G,K)));
}}};
A.prototype.getUIContext=function(){return this._uiContext;
};
A.prototype.setNewQuery=function(D){Logging.log("browse-change-state",D);
var C;
if("id" in D){C=new B.parallax.SingleTopicCollectionDefinition(D.id,D.label);
}else{if("ids" in D){C=new B.parallax.MultipleTopicCollectionDefinition(D["ids"],"names" in D?D["names"]:[]);
}else{C=new B.parallax.RootTypeCollectionDefinition(D.typeID,"search" in D?D.search:null);
}}var E=new B.parallax.Collection(C);
this._internalNewCollection(E,"New search");
};
A.prototype.browseNewCollection=function(C){this._showExplanation=this._trailPoints.length>0&&!this._trailPoints[this._trailPointIndex].collection.isSingular()&&!C.isSingular();
this._internalNewCollection(C,"Pivot",{fadeIn:this._trailPoints.length==1,animate:this._trailPointIndex==this._trailPoints.length-1});
};
A.prototype.browseNewTopic=function(D,C){this._internalNewCollection(new B.parallax.Collection(new B.parallax.SingleTopicCollectionDefinition(D,C)),"Focus",{fadeIn:this._trailPoints.length==1,animate:this._trailPointIndex==this._trailPoints.length-1});
};
A.prototype.selectTrailPoint=function(C){this._switchCollection(C);
};
A.prototype._switchCollection=function(D){var E=this._trailPointIndex;
var C=this;
B.ui.history.addLengthyAction(function(){C._internalSwitchCollection(C._trailPoints,D,false);
},function(){C._internalSwitchCollection(C._trailPoints,E,false);
},"Switch collection");
};
A.prototype._internalNewCollection=function(I,G){var F=new B.parallax.TrailPoint(new B.ui.UIContext(this.getUIContext()),I);
if(this._trailPoints.length>0){var D=[].concat(this._trailPoints);
var H=this._trailPointIndex;
var J=this._trailPointIndex+1;
var C=this._trailPoints.slice(0,J);
C.push(F);
var E=this;
B.ui.history.addLengthyAction(function(){E._internalSwitchCollection(C,J,true);
},function(){E._internalSwitchCollection(D,H,false);
},G);
}else{this._internalSwitchCollection([F],0,false);
}};
A.prototype._internalSwitchCollection=function(C,E,D){this._trailPoints=C;
this._trailPointIndex=E;
this._listeners.fire(D?"onNewTrailPoint":"onSwitchTrailPoint",[C[E],E]);
};
A.prototype.showQuery=function(D){var C="http://www.freebase.com/tools/queryeditor?q="+JSON.stringify(D);
window.open(C,"_blank");
};
A.prototype._playback=function(E){var C=E.length-1;
var F=0;
var D=this;
var G=function(){try{if(F<E.length){var J=E[F];
if("sel" in J&&J.sel){C=F;
}var H=B.parallax.TrailPoint.reconstructFromState(new B.ui.UIContext(D.getUIContext()),J,F==0?null:D._trailPoints[F-1].collection);
D._trailPoints.push(H);
F++;
H.playback(J.s,G);
}else{D._internalSwitchCollection(D._trailPoints,C,false);
}}catch(I){log(I);
}};
G();
};
A.prototype.getState=function(){var E=[];
try{var D=this._trailPointIndex;
while(D>0&&!this._trailPoints[D].collection.isSingular()){D--;
}for(var C=D;
C<=this._trailPointIndex;
C++){var G=this._trailPoints[C].getState();
E.push(G);
}return E;
}catch(F){log(F);
}};
A.prototype.getPermanentLink=function(){var C=document.location.href;
var D=C.indexOf("?");
if(D>0){C=C.substr(0,D);
}return C+"?state="+rison.encode(this.getState()).replace(/ /g,"%20");
};
A.prototype.showPermanentLink=function(){var C=this.getPermanentLink();
Logging.log("show-permanent-link",C);
window.prompt("Permanent link to copy:",C);
};
})();


/* collection-bound-view-container.js */
(function(){var B=window.MetawebSuite;
var A=B.parallax.CollectionBoundViewContainer=function(D,E,C){this._uiContext=D;
this._view=C;
this._div=null;
this._collection=E;
this._collection.addListener(this);
};
A.prototype.dispose=function(){this._view.dispose();
this._view=null;
this._collection=null;
this._uiContext=null;
};
A.prototype.installUI=function(C){this._div=C;
C.innerHTML='<div id="results-summary-container"></div><div class="view-container"></div>';
this._dom={summaryContainer:C.childNodes[0],viewContainer:C.childNodes[1]};
this._view.installUI(this._dom.viewContainer);
this._startRenderView();
};
A.prototype.uninstallUI=function(){this._view.uninstallUI();
this._div=null;
this._dom=null;
};
A.prototype.onItemsChanged=function(){if(this._div!=null){this._startRenderView();
}};
A.prototype._startRenderView=function(){this._startRenderSummary();
this._view.renderExpression(new B.freebase.PathExpression._Impl(this._collection.getMplNode()));
};
A.prototype._startRenderSummary=function(){if(!this._collection.isSingular()){this._dom.summaryContainer.innerHTML='<div class="status"><img src="'+B.ui.params.baseUrl+'images/progress-running.gif" /> Retrieving information...</div>';
var D=this;
var F;
var C=function(G){F=G;
D._collection.getRestrictedItemCount(E,B.system.exception);
};
var E=function(G){D._tryRenderSummary(G,F);
};
this._collection.getAllItemCount(C,B.system.exception);
}};
A.prototype._tryRenderSummary=function(D,E){this._renderSummary(null,D,E);
var C=this;
B.freebase.schemas.tryGetTypeLabel(C._collection.getDefinition(),function(F){C._renderSummary(F,D,E);
});
};
A.prototype._renderSummary=function(C,E,F){var D="";
if(C!=null){D+='<span class="results-summary-type">'+C+"</span>: ";
}if(E==F){D+='<span class="results-summary-count">'+F+" topics</span>";
}else{D+='<span class="results-summary-count">'+E+" topics</span> filtered from <span results-summary-original-count>"+F+"</span> originally";
}this._dom.summaryContainer.innerHTML=D;
};
})();


/* facet-panel.js */
(function(){var C=window.MetawebSuite;
var A=C.parallax.FacetPanel=function(D){this._uiContext=D;
this._layerManager=new C.parallax.TrailPointBoundLayerManager(D,B,this);
};
A.maxFacetSuggestions=7;
A.highFacetRatio=0.5;
A.lowFacetRatio=0.01;
A.prototype.dispose=function(){this._layerManager.dispose();
this._layerManager=null;
this._uiContext=null;
};
A.prototype.installUI=function(D){this._layerManager.installUI(D);
};
A.prototype.uninstallUI=function(){this._layerManager.uninstallUI();
};
var B=C.parallax.FacetPanelLayer=function(F,G,E){this._uiContext=F;
this._collection=E.collection;
this._div=null;
this._baseTypeStack=new C.freebase.TypeStack(this._collection.addBaseRestrictions());
this._textSearchFacet=new TextSearchFacet(new C.ui.UIContext(F),this._collection,{});
this._facetRecords=[];
var D=this;
this._onClickShowMoreFilters=function(H){D._showMoreFilters();
};
this._facetRemover=function(H){D._removeFacet(H);
};
};
B.prototype.dispose=function(){this.uninstallUI();
this._baseTypeStack=null;
this._textSearchFacet=null;
this._facetRecords=null;
this._uiContext=null;
this._collection=null;
this._div=null;
};
B.prototype.installUI=function(E){this._div=E;
if(this._collection.isSingular()){E.innerHTML="";
E.style.display="none";
}else{var D=this;
E.style.display="block";
this._dom=B._fillInDom(E);
myJQuery(this._dom.addFiltersAction).click(this._onClickShowMoreFilters);
this._baseTypeStack.runWhenInitialized(function(){if(D._hasUI()){D._installFacetUI();
D._tryAddMoreFacets();
}});
}};
B._fillInDom=function(E){E.innerHTML='<div></div><div class="facet-pane-heading">Filter Results</div><div class="facet-pane-controls" style="display: none;"><a href="javascript:{}" class="action">more filters &raquo;</a></div><div></div><div class="facet-pane-status-section"><img src="'+C.ui.params.baseUrl+'images/progress-running.gif" /> Suggesting useful filters...</div>';
var D={textSearchFacetContainer:E.childNodes[0],heading:E.childNodes[1],controlContainer:E.childNodes[2],facetContainer:E.childNodes[3],statusSection:E.childNodes[4]};
D.addFiltersAction=D.controlContainer.getElementsByTagName("a")[0];
return D;
};
B.prototype.uninstallUI=function(){if(this._div!=null){myJQuery(this._dom.addFiltersAction).unbind("click",this._onClickShowMoreFilters);
this._div=null;
this._dom=null;
}};
B.prototype._hasUI=function(){return this._div!=null;
};
B.prototype._tryAddMoreFacets=function(){if(this._collection.isSingular()){return ;
}if(this._facetRecords.length<A.maxFacetSuggestions){var D=this;
if(this._baseTypeStack.runOnDimensionsOfNextType(function(E,F){if(D._hasUI()){D._addMoreFacets(E,F);
}})){this._dom.statusSection.style.display="block";
this._dom.controlContainer.style.display="none";
return ;
}}this._dom.statusSection.style.display="none";
this._dom.controlContainer.style.display="block";
};
B.prototype._addMoreFacets=function(D,F){if(this._facetRecords.length==0&&this._baseTypeStack.getTypeCount()>1){var H=new ListFacet(new C.ui.UIContext(this._uiContext),this._collection,{path:C.freebase.PropertyPath.createForwardPath(["/type/object/type"]),label:"Types of Topic",fullLabel:"Types of Topic",expectedType:"/type/type",expectedTypeLabel:"Type",facetRemover:this._facetRemover});
this._appendFacet(H);
}for(var E=0;
E<F.length;
E++){var G=F[E];
if(G.count>Math.max(1,D.count*A.lowFacetRatio)&&G.count<D.count*A.highFacetRatio){G.score=G.count;
}else{G.score=0;
}}F.sort(function(J,I){return I.score-J.score;
});
for(var E=0;
E<F.length&&this._facetRecords.length<A.maxFacetSuggestions;
E++){var G=F[E];
if(G.score>0&&!this._alreadyHasFacetWithPath(G.getPath())){this._appendFacetGivenDimension(G);
}}this._tryAddMoreFacets();
};
B.prototype._alreadyHasFacetWithPath=function(G){var D=G.toString();
for(var E=0;
E<this._facetRecords.length;
E++){var F=this._facetRecords[E].facet.getPath();
if(F.toString()==D){return true;
}}return false;
};
B.prototype._appendFacetGivenDimension=function(D){var E=this._constructFacetGivenDimension(D);
this._appendFacet(E);
return E;
};
B.prototype._prependFacetGivenDimension=function(D){var E=this._constructFacetGivenDimension(D);
this._prependFacet(E);
return E;
};
B.prototype._constructFacetGivenDimension=function(D){return new ListFacet(new C.ui.UIContext(this._uiContext),this._collection,{path:D.getPath(),label:D.label,fullLabel:D.fullLabel,expectedType:D.expectedType,expectedTypeLabel:D.expectedTypeLabel,facetRemover:this._facetRemover});
};
B.prototype._appendFacet=function(E){this._facetRecords.push({facet:E});
var D=C.ui.createHTMLElement("div");
this._dom.facetContainer.appendChild(D);
E.installUI(D);
};
B.prototype._prependFacet=function(F){this._facetRecords.unshift({facet:F});
var E=B._createFacetContainer();
var D=this._dom.facetContainer;
if(D.firstChild==null){D.appendChild(E);
}else{D.insertBefore(E,D.firstChild);
}F.installUI(E);
};
B._createFacetContainer=function(){return C.ui.createHTMLElement("div");
};
B.prototype._installFacetUI=function(){this._textSearchFacet.installUI(this._dom.textSearchFacetContainer);
var D=this._dom.facetContainer;
for(var E=0;
E<this._facetRecords.length;
E++){var F=C.ui.createHTMLElement("div");
D.appendChild(F);
this._facetRecords[E].facet.installUI(F);
}};
B.prototype._uninstallFacetUI=function(){this._textSearchFacet.uninstallUI();
for(var D=0;
D<this._facetRecords.length;
D++){this._facetRecords[D].facet.uninstallUI();
}};
B.prototype._removeFacet=function(F){for(var D=0;
D<this._facetRecords.length;
D++){var E=this._facetRecords[D].facet;
if(E==F){F.uninstallUI();
F.dispose();
this._facetRecords.splice(D,1);
if(this._dom!=null){this._dom.facetContainer.removeChild(this._dom.facetContainer.childNodes[D]);
}}}};
B.prototype._showMoreFilters=function(){Logging.log("show-more-facets",{});
var D=this;
C.ui.widgets.DimensionPickerWidget.show(this._dom.addFiltersAction,this._baseTypeStack.getAllDimensions(),function(E){Logging.log("add-facet",{path:E.getPath().toString()});
D._prependFacetGivenDimension(E);
},[]);
};
})();


/* list-facet.js */
function ListFacet(A,C,B){this._uiContext=A;
this._collection=C;
this._settings=B;
this._selection=[];
this._div=null;
this._dom=null;
this._queryNode=null;
this._choiceEntries=null;
this._showAll=false;
this._sortMode="count";
this._sortDirection="forward";
C.addFacet(this);
}ListFacet.abbreviatedCount=7;
ListFacet.reconstructFromState=function(F,B,I,A){var M=decompressPath(B.p);
var H="";
var K="";
var E="";
var D="";
for(var G=0;
G<M.length;
G++){if(G>0){H+="/";
}var L=M[G].property;
var J=SchemaUtil.propertyRecords[L];
if(J==null){if(L=="/type/object/type"){K="Types of topic";
E="/type/type";
D="Type";
}}else{K=J.name;
E=J.expectedType;
D=J.expectedTypeLabel;
}H+=K;
}var C=new ListFacet(F,I,{path:M,label:K,fullLabel:H,expectedType:E,expectedTypeLabel:D,facetRemover:A});
if("s" in B){C._selection=[].concat(B.s);
}return C;
};
ListFacet.prototype.dispose=function(){this._uiContext=null;
this._collection.removeFacet(this);
this._collection=null;
this._div=null;
this._dom=null;
this._queryNode=null;
this._choiceEntries=null;
};
ListFacet.prototype.getState=function(){var A={p:compressPath(this._settings.path)};
if(this._selection.length>0){A.s=[].concat(this._selection);
}return A;
};
ListFacet.prototype.getPath=function(){return this._settings.path;
};
ListFacet.prototype.hasRestrictions=function(){return this._selection.length>0;
};
ListFacet.prototype.installUI=function(A){this._div=A;
this._constructUI();
this._updateUI();
};
ListFacet.prototype.uninstallUI=function(){if(this._dom!=null){this._dom.label.onclick=null;
this._dom.mapAction.onclick=null;
this._dom=null;
this._div=null;
}};
ListFacet.prototype.onModeChanged=function(A){if(this._dom!=null){if(A=="debug"){this._dom.showQueryAction.style.display=mw.system.debug?"inline":"none";
}}};
ListFacet.prototype.update=function(A){this._queryNode=A;
if(this._dom!=null){this._updateUI();
}};
ListFacet.prototype.restrict=function(A){if(this._selection.length>0){var B=null;
this._settings.path.forEachSegment(function(C){var D={};
A["f:"+mw.freebase.PropertyPath.segmentToForwardMqlKey(C)]=[D];
if(B==null){B=D;
}A=D;
});
A["id|="]=this._selection;
B["limit"]=0;
}};
ListFacet.prototype.getMplNode=function(D){var A=[];
this._settings.path.forEachSegment(function(E){A.push(new mw.freebase.PathExpression._Constant((E.forward?"":"!")+E.propertyID,"freebase-id"));
});
var C=[];
for(var B=0;
B<this._selection.length;
B++){C.push(new mw.freebase.PathExpression._Constant(this._selection[B],"freebase-id"));
}D=new mw.freebase.PathExpression._FunctionCall("filter",[D,new mw.freebase.PathExpression._ConstantArray(A),new mw.freebase.PathExpression._ConstantArray(C)]);
return D;
};
ListFacet.prototype._constructUI=function(){var A=this;
var D=mw.ui.createHTMLElement("div");
D.className="facet";
this._div.appendChild(D);
this._dom=ListFacet._fillInDom(D);
var B=this._settings.label;
var C=B.indexOf(" (");
if(C>0){B=B.substr(0,C);
}this._dom.label.appendChild(document.createTextNode(B));
this._dom.label.title=this._settings.full+" - "+this._settings.path.toString();
this._dom.closeButton.onclick=function(){A._settings.facetRemover(A);
};
this._dom.resetAction.onclick=function(){A._reset();
};
this._dom.showAllAction.onclick=function(){A._showAllChoices();
};
this._dom.showTopChoicesAction.onclick=function(){A._showTopChoices();
};
this._dom.settingsAction.onclick=function(){A._configure();
};
if(this._settings.expectedType=="/location/location"){this._dom.mapAction.style.display="inline";
this._dom.mapAction.onclick=function(){A._map();
};
}this._dom.showQueryAction.onclick=function(){A._showQuery();
};
if(mw.system.debug){this._dom.showQueryAction.style.display="inline";
}};
ListFacet._fillInDom=function(G){G.innerHTML='<div class="facet-header"><img class="facet-header-close" src="'+mw.ui.params.baseUrl+'images/close-button.png" /><span class="facet-header-label"></span><a href="javascript:{}" class="action" style="display: none;">reset</a><a href="javascript:{}" class="action" style="display: none;">map</a><a href="javascript:{}" class="action" style="display: none;">query</a></div><div class="facet-body" style="display: none;"></div><div class="facet-status-section status"><img src="'+mw.ui.params.baseUrl+'images/progress-running.gif" /> Working...</div><div class="facet-footer"><a href="javascript:{}" class="action" style="display: none;">more choices...</a><a href="javascript:{}" class="action" style="display: none;">show top choices only</a><span style="display: none;">&bull;</span><a href="javascript:{}" class="action">settings &raquo;</a></div>';
var C=G.getElementsByTagName("div");
var E=C[0];
var D=C[3];
var F=E.getElementsByTagName("a");
var B=D.getElementsByTagName("a");
var A=D.getElementsByTagName("span");
return{headerDiv:E,closeButton:E.getElementsByTagName("img")[0],label:E.getElementsByTagName("span")[0],resetAction:E.getElementsByTagName("a")[0],mapAction:E.getElementsByTagName("a")[1],showQueryAction:E.getElementsByTagName("a")[2],bodyDiv:C[1],statusSection:C[2],footerDiv:D,showAllAction:B[0],showTopChoicesAction:B[1],settingsAction:B[2],footerSeparators:A};
};
ListFacet._createFacetChoiceDom=function(){var A=mw.ui.createHTMLElement("div");
A.innerHTML='<a href="javascript:{}" class="facet-choice-label"></a><span class="facet-choice-count"></span><a href="javascript:{}" class="facet-choice-action action"></a>';
return{div:A,label:A.getElementsByTagName("a")[0],count:A.getElementsByTagName("span")[0],action:A.getElementsByTagName("a")[1]};
};
ListFacet.prototype._updateUI=function(){if(this._queryNode!=null){this._startRenderChoices();
}};
ListFacet.prototype._pivot=function(){onNewCollection(new Collection(new PivotedCollectionDefinition(this._collection,this._settings.path,this._settings.label)));
};
ListFacet.prototype._map=function(){var A=mw.system.clone(this._settings.path);
A.push({property:"/location/location/geolocation",forward:true});
trailPoints[trailPointIndex].addView(new MapView(this._collection,this._settings.label,A));
};
ListFacet.prototype._showQuery=function(){showQuery([this._createChoiceQuery()]);
};
ListFacet.prototype._startRenderChoices=function(){if(this._queryNode!=null){this._dom.bodyDiv.style.display="block";
this._dom.statusSection.style.display="block";
var A=this;
mw.freebase.mql.read([this._createChoiceQuery()],function(B){A._onRenderChoicesResults(B.result);
},function(B,C){genericErrorHandler(B,C);
A._dom.bodyDiv.style.display="none";
A._dom.statusSection.style.display="none";
});
}};
ListFacet.prototype._createChoiceQuery=function(){var A=mw.system.clone(this._queryNode);
var B=null;
this._settings.path.forEachSegment(function(C){var D={};
D[mw.freebase.PropertyPath.segmentToBackwardMqlKey(C)]=[A];
B=A;
A=D;
});
B["return"]="count";
A["id"]=null;
A["name"]=null;
return A;
};
ListFacet.prototype._onRenderChoicesResults=function(B){if(this._dom==null){return ;
}var I=this._settings.path;
var G=(I.getSegmentCount()>0)?mw.freebase.PropertyPath.segmentToBackwardMqlKey(I.getLastSegment()):"";
var H=function(J){if(typeof J=="object"&&G in J&&J[G].length>0){return J[G][0];
}return J;
};
var F={};
for(var C=0;
C<this._selection.length;
C++){F[this._selection[C]]=true;
}var D=[];
for(var C=0;
C<B.length;
C++){var A=B[C];
if(A.name!=null){var E=H(A);
if(E>0||A.id in F){D.push({id:A.id,name:A.name,count:E,selected:A.id in F});
}}}this._choiceEntries=D;
this._renderChoices();
};
ListFacet.prototype._renderChoices=function(){var J=this._choiceEntries;
var H=function(T,S){var U=T.name.localeCompare(S.name);
return U!=0?U:T.id.localeCompare(S.id);
};
var B=(this._sortMode=="count")?function(T,S){var U=S.count-T.count;
return U!=0?U:H(T,S);
}:H;
var M=(this._sortDirection=="forward")?B:function(T,S){return -B(T,S);
};
J.sort(M);
if(!this._showAll&&J.length>ListFacet.abbreviatedCount){var E=this._selection.length;
var A=J.slice(0,ListFacet.abbreviatedCount);
var F=J.slice(ListFacet.abbreviatedCount);
var L=[];
for(var N=F.length-1;
N>=0;
N--){var C=F[N];
if(C.selected){F.splice(N,1);
L.unshift(C);
}}var G=L.length;
for(var N=A.length-1;
N>=0&&G>0;
N--){var C=A[N];
if(!C.selected){A.splice(N,1);
G--;
}}J=A.concat(L);
}var I=this._dom.bodyDiv;
I.innerHTML="";
var K=this;
var R=this.hasRestrictions();
var D=document.getElementById("facet-choice-template");
var O=function(T){var S=ListFacet._createFacetChoiceDom();
S.div.className=T.selected?"facet-choice facet-choice-selected":"facet-choice";
S.div.style.display="block";
S.label.appendChild(document.createTextNode(T.name));
S.label.onclick=function(U){K._onFacetChoiceClick(T);
};
S.count.appendChild(document.createTextNode("("+T.count+")"));
S.action.style.display=R?"inline":"none";
if(R){if(T.selected){S.action.appendChild(document.createTextNode("remove"));
S.action.onclick=function(U){K._removeRestriction(T.id);
};
}else{S.action.appendChild(document.createTextNode("add"));
S.action.onclick=function(U){K._addAlsoRestriction(T.id);
};
}}I.appendChild(S.div);
};
for(var N=0;
N<J.length;
N++){O(J[N]);
}var P=function(S,T){S.style.display=T;
};
var Q=function(S,T){S.className=T;
};
if(this._choiceEntries.length<=ListFacet.abbreviatedCount){P(this._dom.showAllAction,"none");
P(this._dom.showTopChoicesAction,"none");
P(this._dom.footerSeparators[0],"none");
Q(I,"facet-body");
}else{P(this._dom.footerSeparators[0],"inline");
if(this._showAll){P(this._dom.showAllAction,"none");
P(this._dom.showTopChoicesAction,"inline");
Q(I,"facet-body-scrollable");
}else{P(this._dom.showAllAction,"inline");
P(this._dom.showTopChoicesAction,"none");
Q(I,"facet-body");
}}P(this._dom.statusSection,"none");
P(this._dom.resetAction,this._selection.length>0?"inline":"none");
};
ListFacet.prototype._showAllChoices=function(){Logging.log("facet-show-all-choices",{path:this._settings.path.toString()});
this._showAll=true;
this._renderChoices();
};
ListFacet.prototype._showTopChoices=function(){Logging.log("facet-top-choices",{path:this._settings.path.toString()});
this._showAll=false;
this._renderChoices();
};
ListFacet.prototype._onFacetChoiceClick=function(A){if(A.selected&&this._selection.length==1){this._removeRestriction(A.id);
}else{this._addOnlyRestriction(A.id);
}};
ListFacet.prototype._addOnlyRestriction=function(A){Logging.log("facet-add-only-restriction",{path:this._settings.path.toString(),choiceID:A});
this._applySelection([A],"Select "+A);
};
ListFacet.prototype._addAlsoRestriction=function(A){Logging.log("facet-add-also-restriction",{path:this._settings.path.toString(),choiceID:A});
this._applySelection([].concat(this._selection,A),"Also select "+A);
};
ListFacet.prototype._removeRestriction=function(C){Logging.log("facet-remove-restriction",{path:this._settings.path.toString(),choiceID:C});
var A=[];
for(var B=0;
B<this._selection.length;
B++){if(C!=this._selection[B]){A.push(this._selection[B]);
}}this._applySelection(A,"Unselect "+C);
};
ListFacet.prototype._reset=function(){Logging.log("facet-reset-restrictions",{path:this._settings.path.toString()});
this._applySelection([],"Reset selection");
};
ListFacet.prototype._applySelection=function(A,D){var C=this;
var B=this._selection;
mw.ui.history.addLengthyAction(function(){C._selection=A;
C._notifyCollection();
},function(){C._selection=B;
C._notifyCollection();
},D);
};
ListFacet.prototype._notifyCollection=function(){this._collection.onFacetUpdated(this);
};
ListFacet.prototype._getParallaxApp=function(){return mw.parallax.getParallaxApp(this._uiContext);
};


/* text-search-facet.js */
function TextSearchFacet(A,C,B){this._uiContext=A;
this._collection=C;
this._settings=B;
this._query=null;
this._div=null;
this._dom=null;
C.addFacet(this);
}TextSearchFacet.reconstructFromState=function(A,B,C,E){var D=new TextSearchFacet(A,C,{});
if("q" in B){D._query=B.q;
}return D;
};
TextSearchFacet.prototype.dispose=function(){this._uiContext=null;
this._collection.removeFacet(this);
this._collection=null;
this._div=null;
this._dom=null;
this._query=null;
};
TextSearchFacet.prototype.getState=function(){var A={};
if(this._query!=null){A.q=this._query;
}return A;
};
TextSearchFacet.prototype.hasRestrictions=function(){return this._query!=null;
};
TextSearchFacet.prototype.installUI=function(A){this._div=A;
this._constructUI();
this._updateUI();
};
TextSearchFacet.prototype.uninstallUI=function(){if(this._dom!=null){this._dom.input.onkeydown=null;
this._dom.resetAction.onclick=null;
this._dom=null;
this._div=null;
}};
TextSearchFacet.prototype.onModeChanged=function(A){};
TextSearchFacet.prototype.update=function(A){};
TextSearchFacet.prototype.restrict=function(A){if(this._query!=null){A["name~="]=this._query+"*";
}};
TextSearchFacet.prototype._constructUI=function(){var A=this;
var B=mw.ui.createHTMLElement("div");
B.className="facet";
this._div.appendChild(B);
this._dom=TextSearchFacet._fillInDom(B);
this._dom.input.onkeydown=function(C){return A._onKeyDown(C);
};
this._dom.resetAction.onclick=function(C){A._reset();
};
};
TextSearchFacet._fillInDom=function(C){C.innerHTML='<div class="facet-header"><span class="facet-header-label">Search within Results</span><a href="javascript:{}" class="facet-header-action" style="display: none;">reset</a></div><div class="text-search-facet-input-container"><input></input></div><div class="text-search-facet-status" style="display: none">Searched for: <span class="text-search-facet-query"></span>.<a href="javascript:{}" class="facet-header-action">clear</a></div>';
var A=C.getElementsByTagName("div");
var B={headerDiv:A[0],inputDiv:A[1],statusDiv:A[2]};
B.input=B.inputDiv.firstChild;
B.pastQuery=B.statusDiv.getElementsByTagName("span")[0];
B.resetAction=B.statusDiv.getElementsByTagName("a")[0];
return B;
};
TextSearchFacet.prototype._updateUI=function(){if(this._query!=null){this._dom.statusDiv.style.display="block";
this._dom.pastQuery.innerHTML=this._query;
}else{this._dom.statusDiv.style.display="none";
}};
TextSearchFacet.prototype._onKeyDown=function(A){if(A.keyCode==13){var B=String.trim(this._dom.input.value);
if(B.length==0){B=null;
}Logging.log("facet-search",{"query":B});
this._applySelection(B);
}};
TextSearchFacet.prototype._reset=function(){Logging.log("facet-search-reset",{});
this._applySelection(null,"Clear text search");
};
TextSearchFacet.prototype._applySelection=function(C){var A=this;
var B=this._query;
mw.ui.history.addLengthyAction(function(){A._query=C;
A._updateUI();
A._notifyCollection();
},function(){A._query=B;
A._updateUI();
A._notifyCollection();
},"Search for "+C);
};
TextSearchFacet.prototype._notifyCollection=function(){this._collection.onFacetUpdated(this);
};


/* history-panel.js */
(function(){var B=window.MetawebSuite;
var A=B.parallax.HistoryPanel=function(D){this._uiContext=D;
this._parallaxApp=B.parallax.getParallaxApp(D);
this._div=null;
var C=this;
this._listener={onNewTrailPoint:function(E,F){C._rerender(true,E,F);
},onSwitchTrailPoint:function(E,F){C._rerender(false,E,F);
}};
this._parallaxApp.addListener(this._listener);
};
A.prototype.dispose=function(){this.uninstallUI();
this._parallaxApp.removeListener(this._listener);
this._parallaxApp=null;
this._uiContext=null;
};
A.prototype.installUI=function(C){this._div=C;
this._rerender(false,this._parallaxApp.getCurrentTrailPoint(),this._parallaxApp.getCurrentTrailPointIndex());
};
A.prototype.uninstallUI=function(){this._div=null;
};
A.prototype._rerender=function(T,E,H){if(this._div==null){return ;
}var K=this._div;
K.innerHTML="";
var G=this._parallaxApp.getTrailPointCount();
if(G<2){return ;
}var M=H==1&&T;
var F=T;
var R=Math.min(G-1,H+2);
var O=Math.max(0,R-4);
if(O>0){var Q=B.ui.createHTMLElement("span");
Q.innerHTML="&bull;&bull;&bull; ";
K.appendChild(Q);
}var P=B.ui.createHTMLElement("span");
P.style.visibility="hidden";
K.appendChild(P);
var I=B.ui.createHTMLElement("span");
I.style.visibility="hidden";
K.appendChild(I);
var L=this;
var J=function(Z,V){var U=(Z==H);
var X=L._parallaxApp.getTrailPoint(Z);
var b=X.collection;
var Y=b.getLabel();
if(Z<H&&!b.isSingular()){var W=b.getCountLabel();
if(W!=null){Y+=" ("+W+")";
}}var a=B.ui.createHTMLElement("span");
a.className=U?"history-entry history-entry-selected":"history-entry";
a.innerHTML=Y;
a.style.display="inline";
if(!U){myJQuery(a).click(function(){Logging.log("trail-point-select",Z);
L._parallaxApp.selectTrailPoint(Z);
});
}V.appendChild(a);
};
for(var S=O;
S<=R;
S++){J(S,S<H?P:I);
}if(R<G-1){var Q=B.ui.createHTMLElement("span");
Q.innerHTML=" &bull;&bull;&bull;";
I.appendChild(Q);
}if(F){var N=I.offsetWidth+10;
var C=200;
var D=C-N;
K.style.paddingRight=D+"px";
new B.ui.Animation(function(V,U){K.style.paddingRight=V+"px";
},D,C,1000).run();
}I.style.visibility="visible";
if(M){$(P).fadeIn("slow");
}P.style.visibility="visible";
};
})();


/* pivot-panel.js */
(function(){var C=window.MetawebSuite;
var A=C.parallax.PivotPanel=function(D){this._uiContext=D;
this._layerManager=new C.parallax.TrailPointBoundLayerManager(D,B,this);
};
A.maxPivotSuggestions=5;
A.prototype.dispose=function(){this._layerManager.dispose();
this._layerManager=null;
this._uiContext=null;
};
A.prototype.installUI=function(D){this._layerManager.installUI(D);
};
A.prototype.uninstallUI=function(){this._layerManager.uninstallUI();
};
var B=C.parallax.PivotPanelLayer=function(F,G,E){this._uiContext=F;
this._collection=E.collection;
this._div=null;
this._currentTypeStack=new C.freebase.TypeStack(this._collection.addRestrictions());
this._pivotDimensions=[];
var D=this;
this._onClickShowMoreConnections=function(H){D._showMoreConnections();
};
this._collection.addListener(this);
};
B.prototype.dispose=function(){this.uninstallUI();
this._currentTypeStack.dispose();
this._currentTypeStack=null;
this._pivotDimension=null;
this._collection.removeListener(this);
this._collection=null;
this._uiContext=null;
};
B.prototype.installUI=function(F){var E=this;
this._div=F;
this._dom=B._fillInDom(F);
myJQuery(this._dom.showMoreRelatedTopicsAction).click(this._onClickShowMoreConnections);
var D=this._collection.isSingular();
if(D){this._dom.header.style.display="none";
this._dom.pivotContainer.style.display="none";
this._dom.statusSection.style.display="none";
this._dom.footer.style.display="none";
}else{this._currentTypeStack.runWhenInitialized(function(){if(E._hasUI()){E._installPivotUI();
E._tryAddMorePivots();
}});
}};
B._fillInDom=function(E){E.innerHTML='<div class="pivot-pane-sign"><img src="'+C.parallax.params.baseUrl+'images/parallax-sign-white.png" /></div><div class="pivot-pane-header">Connections from the topics on this page:</div><div class="pivot-pane-body"></div><div class="pivot-pane-status-section status"><img src="'+C.ui.params.baseUrl+'images/progress-running.gif" /> Finding connections...</div><div class="pivot-pane-footer" style="display: none;"><a href="javascript:{}" class="action">more connections &raquo;</a></div>';
var D={header:E.childNodes[1],pivotContainer:E.childNodes[2],statusSection:E.childNodes[3],footer:E.childNodes[4]};
D.showMoreRelatedTopicsAction=D.footer.childNodes[0];
return D;
};
B.prototype._hasUI=function(){return this._div!=null;
};
B.prototype.uninstallUI=function(){if(this._div!=null){myJQuery(this._dom.showMoreRelatedTopicsAction).unbind("click",this._onClickShowMoreConnections);
this._div=null;
this._dom=null;
}};
B.prototype.onItemsChanged=function(){this._currentTypeStack.dispose();
this._currentTypeStack=new C.freebase.TypeStack(this._collection.addRestrictions());
this._pivotDimensions=[];
if(this._hasUI()){this._dom.pivotContainer.innerHTML="";
this._tryAddMorePivots();
}};
B.prototype._tryAddMorePivots=function(){if(this._pivotDimensions.length<A.maxPivotSuggestions){var D=this;
if(this._currentTypeStack.runOnDimensionsOfNextType(function(E,F){if(D._hasUI()){D._addMorePivots(E,F);
}})){this._dom.statusSection.style.display="block";
this._dom.footer.style.display="none";
return ;
}}this._dom.statusSection.style.display="none";
this._dom.footer.style.display="block";
};
B.prototype._addMorePivots=function(F,H){for(var G=0;
G<H.length;
G++){var I=H[G];
I.score=(I.expectedType=="/people/person")?(2*I.count):I.count;
}H.sort(function(L,K){return K.score-L.score;
});
var E=this;
var J=this._dom.pivotContainer;
var D=function(K){E._appendPivotGivenDimension(K);
E._pivotDimensions.push(K);
};
for(var G=0;
G<H.length&&this._pivotDimensions.length<A.maxPivotSuggestions;
G++){var I=H[G];
if(I.score>F.count/2&&I.score<F.count*10){D(I);
}}this._tryAddMorePivots();
};
B.prototype._installPivotUI=function(){var D=this._dom.pivotContainer;
for(var E=0;
E<this._pivotDimensions.length;
E++){this._appendPivotGivenDimension(this._pivotDimensions[E]);
}};
B.prototype._appendPivotGivenDimension=function(H){var D=this;
var E=H.label;
var G=E.indexOf(" (");
if(G>0){E=E.substr(0,G);
}var F=B._createPivotChoiceDom(E,H.count,H.fullLabel);
F.label.onclick=function(){Logging.log("pivot",{path:H.getPath().toString(),suggested:true});
D._pivot(H);
};
this._dom.pivotContainer.appendChild(F.div);
};
B._createPivotChoiceDom=function(D,E,F){var G=C.ui.createHTMLElement("div");
G.className="pivot-choice";
G.innerHTML='<a href="javascript:{}">'+D+"</a> ("+E+")";
G.title=F;
return{div:G,label:G.firstChild};
};
B.prototype._showMoreConnections=function(){Logging.log("show-more-pivots",{});
var D=this;
C.ui.widgets.DimensionPickerWidget.show(this._dom.showMoreRelatedTopicsAction,this._currentTypeStack.getAllDimensions(),function(E){Logging.log("pivot",{path:E.getPath().toString(),suggested:false});
D._pivot(E);
},[]);
};
B.prototype._pivot=function(E){var D=C.parallax.getParallaxApp(this._uiContext);
D.browseNewCollection(new C.parallax.Collection(new C.parallax.PivotedCollectionDefinition(this._collection,E.getPath(),E.label)));
};
})();


/* trail-point.js */
(function(){var mw=window.MetawebSuite;
var TrailPoint=mw.parallax.TrailPoint=function(uiContext,collection){this._uiContext=uiContext;
this.collection=collection;
this._dataRecords={};
};
TrailPoint.reconstructFromState=function(uiContext,stateEntry,baseCollection){var trailPointDefn=stateEntry.d;
var collectionDefinition;
if("t" in trailPointDefn){collectionDefinition=new mw.parallax.RootTypeCollectionDefinition(trailPointDefn.t,"s" in trailPointDefn?trailPointDefn.s:null);
}else{if("p" in trailPointDefn){collectionDefinition=new mw.parallax.PivotedCollectionDefinition(baseCollection,mw.freebase.PropertyPath.jsonToPath(trailPointDefn.p),trailPointDefn.l);
}else{collectionDefinition=new mw.parallax.SingleTopicCollectionDefinition(trailPointDefn.i,trailPointDefn.n);
}}var collection=new mw.parallax.Collection(collectionDefinition);
var trailPoint=new TrailPoint(uiContext,collection);
return trailPoint;
};
TrailPoint.prototype.getDataRecord=function(key){return this._dataRecords[key];
};
TrailPoint.prototype.setDataRecord=function(key,dataRecord){this._dataRecords[key]=dataRecord;
};
TrailPoint.prototype.deleteDataRecord=function(key){var record=this._dataRecords[key];
delete this._dataRecords[key];
if(typeof record=="object"&&"dispose" in record){record.dispose();
}};
TrailPoint.prototype.playback=function(state,onDone){var self=this;
if("v" in state){var viewStateArray=state.v;
for(var i=0;
i<this._views.length;
i++){this._views[i].dispose();
}this._views=[];
for(var i=0;
i<viewStateArray.length;
i++){var viewState=viewStateArray[i];
var viewClass=eval(viewState.c);
var view=new viewClass(new mw.ui.UIContext(this._uiContext),this.collection);
view.reconfigureFromState(viewState.s);
this._views.push(view);
}if("vi" in state){this._viewIndex=state.vi;
}}if("f" in state){var facetStateArray=state.f;
var fetchFacetSchemas=function(){var properties={};
for(var i=0;
i<facetStateArray.length;
i++){var facetState=facetStateArray[i];
var path=decompressPath(facetState.p);
for(var j=0;
j<path.length;
j++){properties[path[j].property]=true;
}}var propertiesA=[];
for(var n in properties){if(n!="/type/object/type"){propertiesA.push(n);
}}SchemaUtil.retrievePropertySchemas(propertiesA,constructFacets);
};
var constructFacets=function(){for(var i=0;
i<facetStateArray.length;
i++){var facetState=facetStateArray[i];
var facet=ListFacet.reconstructFromState(new mw.ui.UIContext(self._uiContext),facetState,self.collection,self._facetRemover);
self._facetRecords.push({facet:facet});
}onDone();
};
this._baseTypeStack.runWhenInitialized(fetchFacetSchemas);
}else{onDone();
}};
TrailPoint.prototype.getState=function(){var r={d:this.collection.getDefinition().getState(),s:{}};
if(!this.collection.isSingular()){var facetStateArray=[];
for(var i=0;
i<this._facetRecords.length;
i++){var facetRecord=this._facetRecords[i];
var facet=facetRecord.facet;
if(facet.hasRestrictions()){facetStateArray.push(facet.getState());
}}if(facetStateArray.length>0){r.s.f=facetStateArray;
}}var viewStateArray=[];
for(var i=0;
i<this._views.length;
i++){var view=this._views[i];
var viewState=view.getState();
if(viewState!=null){viewStateArray.push({c:view.getClassName(),s:viewState});
}}if(viewStateArray.length>0){r.s.v=viewStateArray;
r.s.vi=this._viewIndex;
}return r;
};
TrailPoint.prototype.dispose=function(){this.collection=null;
this._uiContext=null;
};
TrailPoint.prototype._getParallaxApp=function(){return mw.parallax.getParallaxApp(this._uiContext);
};
var TrailPointBoundLayerManager=mw.parallax.TrailPointBoundLayerManager=function(uiContext,layerClass,parent){this._uiContext=uiContext;
this._layerClass=layerClass;
this._parent=parent;
this._parallaxApp=mw.parallax.getParallaxApp(uiContext);
this._key="f"+Math.floor(Math.random()*1000000);
this._layer=null;
var self=this;
this._listener={onNewTrailPoint:function(trailPoint,index){self._renderForTrailPoint(trailPoint);
},onSwitchTrailPoint:function(trailPoint,index){self._renderForTrailPoint(trailPoint);
}};
this._parallaxApp.addListener(this._listener);
};
TrailPointBoundLayerManager.prototype._getLayer=function(trailPoint){var layer=trailPoint.getDataRecord(this._key);
if(!(typeof layer=="object")){layer=new this._layerClass(this._uiContext,this._parent,trailPoint);
trailPoint.setDataRecord(this._key,layer);
}return layer;
};
TrailPointBoundLayerManager.prototype.dispose=function(){this.uninstallUI();
this._parallaxApp.removeListener(this._listener);
this._parallaxApp=null;
this._uiContext=null;
};
TrailPointBoundLayerManager.prototype.installUI=function(div){this._div=div;
var trailPoint=this._parallaxApp.getCurrentTrailPoint();
if(trailPoint!=null){this._renderForTrailPoint(trailPoint);
}};
TrailPointBoundLayerManager.prototype.uninstallUI=function(){this._unrenderForTrailPoint();
this._div=null;
};
TrailPointBoundLayerManager.prototype._renderForTrailPoint=function(trailPoint){this._layer=this._getLayer(trailPoint);
if(this._div!=null){this._layer.installUI(this._div);
}};
TrailPointBoundLayerManager.prototype._unrenderForTrailPoint=function(){if(this._layer!=null){if(this._div!=null){this._layer.uninstallUI();
}this._layer=null;
}};
})();


/* logging.js */
var Logging={service:"http://mqlx.com:5555/parallax-logger",_pad2:function(A){return(A<10)?("0"+A):A;
}};
(function(){Logging.id="id"+new Date().getTime()+"x"+Math.floor(1000000*Math.random());
})();
Logging.log=function(A,B){};


/* view-panel.js */
(function(){var C=window.MetawebSuite;
var A=C.parallax.ViewPanel=function(D){this._uiContext=D;
this._layerManager=new C.parallax.TrailPointBoundLayerManager(D,B,this);
};
A.prototype.dispose=function(){this._layerManager.dispose();
this._layerManager=null;
this._uiContext=null;
};
A.prototype.installUI=function(D){this._layerManager.installUI(D);
};
A.prototype.uninstallUI=function(){this._layerManager.uninstallUI();
};
var B=function(E,F,D){this._uiContext=E;
this._collection=D.collection;
this._div=null;
this._viewIndex=0;
this._viewContainers=[];
this.addView(this._collection.isSingular()?new C.views.SingleTopicView(this._uiContext):new C.views.ThumbnailView(this._uiContext));
};
B.prototype.dispose=function(){for(var D=0;
D<this._viewContainers.length;
D++){this._viewContainers[D].dispose();
}this._viewContainers=null;
this._div=null;
this._colleciton=null;
this._uiContext=null;
};
B.prototype.installUI=function(D){this._div=D;
this._viewContainers[this._viewIndex].installUI(D);
};
B.prototype.uninstallUI=function(){this._viewContainers[this._viewIndex].uninstallUI();
this._div=null;
};
B.prototype.addView=function(D){this._viewContainers.push(new C.parallax.CollectionBoundViewContainer(this._uiContext,this._collection,D));
this._selectView(this._viewContainers.length-1);
};
B.prototype._renderViewSelectorPane=function(){var D=this._getParallaxApp()._getViewSelectorPane();
D.innerHTML="";
var G={};
var L=this;
var I=function(M){var O=C.ui.createHTMLElement("span");
var N=(M==L._viewIndex);
O.className=N?"view-selector view-selector-selected":"view-selector";
O.innerHTML=L._views[M].getLabel();
if(!N){O.onclick=function(){Logging.log("view-select",M);
L._selectView(M);
};
}D.appendChild(O);
};
var H=false;
if(this._views.length>1){H=true;
for(var E=0;
E<this._views.length;
E++){I(E);
G[this._views[E].getClassName()]=true;
}}var F=false;
var K=function(O,N){if(!F){F=true;
if(H){D.appendChild(document.createTextNode(" \u2022 "));
}D.appendChild(document.createTextNode("Show results on: "));
}else{D.appendChild(document.createTextNode(", "));
}var M=C.ui.createHTMLElement("a");
M.className="action";
M.innerHTML=N;
M.href="javascript:{}";
M.onclick=function(){Logging.log("add-view",{label:N,suggested:true});
L.addView(new O(L.collection));
};
D.appendChild(M);
};
if(!("MapView" in G)){K(MapView,"Map");
}if(!("TimelineView" in G)){K(TimelineView,"Timeline");
}D.appendChild(document.createTextNode(" \u2022 "));
var J=C.ui.createHTMLElement("a");
J.className="action";
J.innerHTML="more &raquo;";
J.href="javascript:{}";
J.onclick=function(){L._showAddViewPopup(J);
};
D.appendChild(J);
};
B.prototype._selectView=function(E){var D=this._div!=null;
if(D){this._viewContainers[this._viewIndex].uninstallUI();
}this._viewIndex=E;
if(D){this._viewContainers[this._viewIndex].installUI(this._div);
this._renderViewSelectorPane();
}};
B.prototype._showAddViewPopup=function(F){Logging.log("show-more-views",{});
var G=createPopupMenuDom(F);
var D=this;
var E=function(I,H){G.appendMenuItem(H,null,function(){Logging.log("add-view",{label:H,suggested:false});
D.addView(new I(new C.ui.UIContext(D._uiContext),D.collection));
});
};
E(ThumbnailView,"Thumbnails");
E(MapView,"Map");
E(TimelineView,"Timeline");
E(Chart1DView,"Chart 1D");
E(Chart2DView,"Chart 2D");
E(TabularView,"Table");
G.open();
};
})();


/* terminal.js */
window.MetawebSuite.system.onFinishLoadingPackage("metaweb-suite-parallax");


/* persistence-package.js */
(function() {
    mw.system.onStartLoadingNativePackage(
        "persistence",
        [   "change-manager.js",
            "terminal.js"
        ],
        [
            "changes.css"
        ]
    );
})();


/* persistence-bundle.js */


/* change-manager.js */
var ChangeManager={_changes:[],_div:null};
ChangeManager.addChange=function(A){if(ChangeManager._changes.length==0){ChangeManager._addUI();
}ChangeManager._changes.push(A);
};
ChangeManager.hasChanges=function(){return ChangeManager._changes.length>0;
};
ChangeManager._submitData=function(){Logging.log("write",ChangeManager._changes);
ChangeManager._changes=[];
ChangeManager._removeUI();
};
ChangeManager._discardData=function(){if(window.confirm("Discard all of your data contributions?")){ChangeManager._changes=[];
ChangeManager._removeUI();
}};
ChangeManager._addUI=function(){var D=document.createElement("div");
D.className="change-popup";
D.innerHTML="<div>Thank you for your data contributions!</div><div>They are currently not sent in yet. You can continue to contribute more before sending. Or you can send them in now.</div><div><button>Send Now</button> <button>Discard All</button></div>";
var B=D.getElementsByTagName("button");
B[0].onclick=ChangeManager._submitData;
B[1].onclick=ChangeManager._discardData;
ChangeManager._div=D;
document.body.appendChild(D);
var A=0;
var C=window.setInterval(function(){if(A%2==0){D.style.display="none";
}else{D.style.display="block";
}if(A>4){window.clearInterval(C);
}else{A++;
}},200);
};
ChangeManager._removeUI=function(){document.body.removeChild(ChangeManager._div);
ChangeManager._div=null;
};
window.onbeforeunload=function(A){if(ChangeManager.hasChanges()){A.returnValue="Your data contributions have not been submitted. (Look at the bottom right corner of the window.)";
return false;
}};


/* terminal.js */
window.MetawebSuite.system.onFinishLoadingPackage("metaweb-suite-persistence");
